Monday, 7 November 2011

Deploying a VSTO Click Once Add-in - don't forget your MIME Types!

I just wanted to make a note of this for future reference and to help any one that might be struggling with this in the future:

I have just created a simple Excel 2007 office add-in and I wanted to deploy it to a local server on my intranet and allow other users to click a url and install the application. Using the project properties page I configured the relevant server details and successfully published the add-on on to the server.

image

But when I navigated to the specified install url I received 403 error This website requires you to login. After searching the web for a suitable answer I finally stumbled upon the answer on this web site:

http://social.msdn.microsoft.com/Forums/en-MY/winformssetup/thread/10ee1ca1-b3ae-4a6f-98ba-125179b9e417

In summary, don't forget to configure the .'vsto' MIME type with 'application/x-ms-vsto' on the virtual directory containing the add-in.

Wednesday, 5 October 2011

CodeKen - the replacement conference for StackOverflow DevDays

CodeKen London 2011 is a brand new developer conference delivering two days of hands-on coding oriented content over the 14 - 15th November in London. The event was organised in response to the cancellation of the Stackoverflow DevDays conferences and includes many of the original speakers like Jon Skeet, Robert Pickering and Richard Marr.

The talks cover a wide range of subjects including programming style, MongoDB, NodeJS, HTML5, REST services and more.

In addition to an eclectic mix of talks CodeKen 2011 is launching a developer side project competition. The goal is to encourage and publicise developers that are spending their spare time working on interesting projects. Five finalists will be given a free ticket to the conference and a chance to present their project at the event.

See the full conference schedule and more information on the CodeKen Side Project competition on the conference site - http://london2011.codeken.com

Monday, 5 July 2010

NxtGenUG Fest 10 - “Beside the C# side” – Bournemouth 16th July

NxtGenUG are pleased to announce their annual conference Fest10 will be taking place on Bournemouth Pier this year on Friday the  16th July 2010 – It’s a great opportunity to take the family to the Seaside  for the weekend, and catch up on technology. The best thing is attendance to the conference is free to members and just £59.95 for non-members.

Speakers

We have a great speaker line up this year, Google’s Jon Skeet will be talking about C#, Microsoft’s Glenn Block is coming over from Redmond to talk about MEF, Ryan Simpson will be giving us the lowdown on F#. We’ll also be having NxtGenUG veterans Mike Taulty, on OData and Chris Hay on Azure, Plus Marcus Perryman will be talking about one of the hottest technologies this year Windows Phone 7.

You can find a list of speakers and their sessions here

http://www.nxtgenug.net/fest10/Sessions.aspx

To register simply go to the following link and follow the instructions on screen.

http://www.nxtgenug.net/fest10

Parking, Hotels and Timings

Upto date Details on parking, hotel accommodation and timings for the day can be found on the Fest10 site. The nearest parking for Bournemouth Pier is either in the Bournemouth International Centre (BIC - 20) car park, the Bournemouth Pavilion car parks (19/24) or the car park next to the Royal Bath hotel (18). However, there is also further car parking available at Eden Glen car park (21), Winter Gardens car park (22) and Beacon Road car park (25). For Hotels, the RusselCourt is where the evening entertainment will be Quote: NxtGenUG when booking, otherwise Bournemouth has a large amount of hotels, including the Best Western Hotel Royale.

http://www.nxtgenug.net/fest10/

Geek Dinner

It's the Fest10 geek dinner - normal rules apply - pay for your own food/drink, and engage in great conversation, and eat fish and chips at Harry Ramsden’s. To register for the geek dinner

http://www.nxtgenug.net/ViewEvent.aspx?EventID=322

Post Fest Party

We’ll also be having a post Fest Party at the RusselCourt Hotel – If you’ve brought your family down for the weekend feel free to bring them along. Just register on the site and drop us an email on how many people you’ll be bringing with you toenquiries@nxtgenug.net

http://www.nxtgenug.net/ViewEvent.aspx?EventID=325

Sponsorship

NxtGenUG would like to thank DevExpress, our gold sponsor, along with Microsoft, RedGate, PluralSight and Apress for their support in making this event possible.

Monday, 2 November 2009

CSM course in Bournemouth 23 & 24 November

Geoff Watts will be holding a CSM training course in Bournemouth on the 23/11/2009 and 24/11/2009. For full details see here

Monday, 17 August 2009

An ASP .NET Testing Time Ahead

Thursday 20th August sees NxtGenUG Southampton hosting a web application testing session that is not to be missed. Testing guru and general all round community good guy Ben Hall is coming down to pay us a visit and talk about all things web test, Ben will be looking at how you can test different aspects of ASP .NET from the core engine to the UI and databases. Topics will include test driven development, mocking of external services as well as UI automation but probably most importantly Ben will be describing the best way to get started with testing you web application.

All in all this looks like a great session and if you are in the area I would definitely recommend paying us a visit.

Wednesday, 20 May 2009

Unit Testing ASP.NET? ASP.NET unit testing has never been this easy.


Typemock is launching a new product for ASP.NET developers – the ASP.NET Bundle - and for the launch will be giving out FREE licenses to bloggers and their readers.

The ASP.NET Bundle is the ultimate ASP.NET unit testing solution, and offers both Typemock Isolator, a unit test tool and Ivonna, the Isolator add-on for ASP.NET unit testing, for a bargain price.
Typemock Isolator is a leading .NET unit testing tool (C# and VB.NET) for many ‘hard to test’ technologies such as SharePoint, ASP.NET, MVC, WCF, WPF, Silverlight and more. Note that for unit testing Silverlight there is an open source Isolator add-on called SilverUnit.

The first 60 bloggers who will blog this text in their blog and tell us about it, will get a Free Isolator ASP.NET Bundle license (Typemock Isolator + Ivonna). If you post this in an ASP.NET dedicated blog, you'll get a license automatically (even if more than 60 submit) during the first week of this announcement.

Also 8 bloggers will get an additional 2 licenses (each) to give away to their readers / friends.
Go ahead, click the following link for more information on how to get your free license.

Wednesday, 29 April 2009

Using Linq to SQL to validate Data Access Logic

So Microsoft aren't going to be supporting Linq to SQL (L2S) see "Microsoft Kills Linq to SQL" for more info, but there are still some great situations that it can be really useful in your environment with it going into a production build and one of those is using L2S for testing your data access logic.

This post aims to talk you through a way of using L2S to confirm that what you think your data access logic is doing is what your data access logic is actually doing.

A really useful tool that comes with L2S is called SQLMetal, this tool is used to automatically generate a data context based on the current schema of a given database. So instead of using the fancy designer front end, you auto generate the whole database schema including Stored Procedures and Views if you want but you can restrict this if you want by simply not including the required input parameter. To do this every time your application builds simply amend your project file with the following ensuring that you replace the text in [] with your specific fields:

<Target Name="BeforeBuild">
<
Exec Command="&quot;C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin\SqlMetal.exe&quot; /server:[ServerName] /Database:[DatabaseName] /code:[MyDataContext].cs /context:[MyDataContext] /namespace:[MyCompany].[MyProject].DataAccess /views /sprocs /functions /pluralize WorkingDirectory="$(ProjectDir)" />
</
Target>



The parameters /views /sprocs /functions will expose all of the views, stored procedures and functions accordingly. The /pluralize parameter indicates that you want to generate plural names for tables so a table called "Customer" will be exposed as "Customers" in the data context. For full details of the parameter list go here. Once you've modified the project file reload it and when you next build the project file it will generate a data context for you with as much of your database exposed as you would like.



So now that we have our data context we can put this to good effect when testing our database access logic, for example take the following data portal insert method from a CSLA business object which will be called when our business object is new and the Save method is called:



protected override void DataPortal_Insert()
{
using (var connection = ConnectionManager<SqlConnection>.GetManager("MyDatabase").Connection)
{
SqlCommand cmd = new SqlCommand();
cmd.CommandType = CommandType.StoredProcedure;
cmd.Connection = connection;
cmd.CommandText = "usp_CreateEmployee";
cmd.Parameters.AddWithValue("@FirstName", ReadProperty(FirstNameProperty));
cmd.Parameters.AddWithValue("@LastName", ReadProperty(LastNameProperty));
cmd.Parameters.AddWithValue("@EmailAddress", ReadProperty(EmailAddressProperty));
cmd.ExecuteNonQuery();
}
}


This method quite simply executes a stored procedure called "usp_CreateEmployee" and passes in the parameters from the business object. What we want to do here is validate that the parameters are correctly passed from our business object into our stored procedure and the stored procedure correctly performs an operation to insert a new employee with the details set on the business object. What we don't want to do here is have to write a whole bunch of code in order to do this, step in L2S.



So now back in our unit test we can do the following:



        [TestMethod]
public void EmployeeIsCreatedInDatabase()
{
TestDataContext = new MyTestDataContext(CreateConnection());

int initialCount = TestDataContext.Employees.Count();

const string FirstName = "TestFirstName";
const string LastName = "TestLastName";
const string EmailAddress = "test@test.com";

// Create business object and set values
var employee = Employee.NewEmployee(CompanyId);
employee.FirstName = FirstName;
employee.LastName = LastName;
employee.EmailAddress = EmailAddress;

// Call save on business object, this will execute data portal logic
// and insert a new row in the database with the new values
employee.Save();

// Refresh our data context with data from the database
TestDataContext.Refresh(RefreshMode.OverwriteCurrentValues);

// Now get the new employee table count and assert it has increased by 1
int newCount = TestDataContext.Employees.Count();
Assert.AreEqual(initialCount + 1, newCount);

// Now get a Linq Employee object directly from the data context and verify that
// the all of the fields have been populated as we expected them to.
LinqEmployee linqEmployee = TestDataContext.Employees.OrderByDescending(e => e.ID).FirstOrDefault();
Assert.IsNotNull(linqEmployee);
Assert.AreEqual(linqEmployee.FirstName, FirstName, "Expected first names to match");
Assert.AreEqual(linqEmployee.LastName, LastName, "Expected last names to match");
Assert.AreEqual(linqEmployee.Email, EmailAddress, "Expected email addresses to match");
}


As you can see from the above code, the test creates a TestDataContext L2S object  and takes an initial count of the number of employees in the Employee table and defines our test values as constants.



Next we create a new employee business object and set the appropriate values with the test data. We then call the Save method on the business object, this is the method we are actually testing and we want to ensure that it correctly passes the information set on the business object down to our data access layer and then the data access layer inserts the appropriate data into the relevant tables.



We can then verify that the Save method has done what it needed to do by using out TestDataContext, we simply refresh the data with values from the database and then perform some assertions. Firstly, we check that the employee count has incremented by 1, this ensures that an insert was performed on the table. Next, we sort the employees by Id and order descending ensuring that we get the latest Id generated by the table - our new employee should be the last row in the table (unfortunately the Last() function in L2S does not work so we have to do this order by descending approach). We then get an instance of this L2S object and perform assertions on its properties ensuring that the data we set on our business object has been set on the L2S object.



Conclusion



Linq to SQL may no longer be supported by Microsoft and as such might not be suitable for production ready systems, but it can still be a really useful tool especially when performing data tests to ensure our data access layers are performing as we expect. I hope you find this post useful and it helps you to get a bit more data access testing done. Let me know your comments.