RSS Feed
 
 
12.22.2009 at 7:37 PM

Integrating/Using NUnit with Visual Studio 2008 Standard and ASP.NET MVC

If you're one of the fortunate that has access to Visual Studio 2008 Professional editions or above, you might be asking, "Why would you want to use NUnit with Visual Studio 2008 Standard?". The answer is, the Standard edition (as well as Express editions) don't come integrated with a unit testing framework, nor do they come with unit testing project templates for ASP.NET MVC like the Professional edition and above. Unit testing has become more popular lately, especially with the advantages it adds for ASP.NET MVC.

However, if you're like me and can't afford the more pricey editions, there are some third party unit testing frameworks you can still use. NUnit is not your only choice, but is one of the more common frameworks and is the one I use, so I'll tell you how to get it working within Visual Studio 2008 Standard (or Visual Web Developer Express) along with debugging support while running your unit tests in ASP.NET MVC projects.

Hit the jump to see how to integrate NUnit
 
4.5.2009 at 9:02 AM

C#.NET - Initialize auto-properties in Visual Studio 2008 like 2005

If you're like me, you like to use the "prop" snippet from Visual Studio 2005. If you don't know what I'm talking about, with a C# file open in Visual Studio 2005 (or 2008), type: prop then hit tab twice. In 2005, you are able to initialize the variable like so:

private string _name = "default"; public string Name { get { return _name; } set { _name = value; } }


However, in 2008, prop tab tab gives you the following..

public string Name { get; set; }


This is a problem because there's no simple quick way to initialize the variable.
You can initialize it in a constructor, but what if you're using a static class? You're only other option is to use a DefaultValue attribute like so:

[DefaultValue("default")] public string Name { get; set; }


The problem with using the DefaultValue attribute is that, as far as I know, it requires using Reflection. So not only is it a pain to type, you also take a performance hit.

The way that 2005 handled it still works in 2008, so the easiest solution is to use the snippet from 2005 in 2008. I have created a propx snippet to handle just that. Simply unzip and put the propx.snippet file into your My Code Snippets folder (in Windows 7 this is located at C:\Users\Gordon\Documents\Visual Studio 2008\Code Snippets\Visual C#\My Code Snippets\), restart visual studio then type propx tab tab to use it.
 
3.11.2009 at 12:06 AM

How to restore missing Windows Service templates in Visual Studio 2005

I needed to write a Windows Service using Visual Studio 2005 Standard at home, however when I went to New Project, I was missing the Windows Service project template. Ok, weird. So a quick web search and I found a post with similar instructions on how to restore the Windows Service project templates.

Basically what it says is, you need to download the Windows Service template zip files:
C# Windows Service Template
VB Windows Service Template
(Hosted at megaupload.com)

Hit the jump to see the remaining instructions on how to restore the Windows Service templates.
 
9.16.2008 at 7:48 PM

ASP.NET 2.0, Visual Studio 2005, and IIS7 on Vista Home Premium

So you want to setup ASP.NET 2.0, Visual Studio 2005, and IIS7 on Vista Home Premium.

I don't want to repeat what someone has done a fantastic job of already, so here is a great article that covers quite a broad range of different scenarios:
http://learn.iis.net/page.aspx/431/using-visual-studio-2005-with-iis-70/

The article mentions one of the issues I had when trying to debug my web site application using Visual Studio 2005 against IIS7 (as opposed to the default ASP.NET web server) on Vista Home Premium. The error message displayed is:
Unable to start debugging on the web server. Debugging failed because integrated Windows authentication is not enabled. Please see Help for assistance.
The article mentions the following hotfix:
http://support.microsoft.com/kb/937523

One issue the article doesn't cover is when you try to view your site in a browser against IIS7 and get an error message similar to this:
CS0016: Could not write to output file 'c:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\Temporary ASP.NET Files\application1\c11b43f6\cf3ec03\rizcntet.dll'. The directory name is invalid.
The following KB article has the fix:
http://support.microsoft.com/kb/825791
Even though the article says it applies to .NET 1.0 and 1.1, it works fine with 2.0. On the step where it says to...
Grant full permissions on the Temp folder to the aspnet user account in .NET Framework 1.0 or to the NETWORK SERVICE user account in .NET Framework 1.1.
...use the NETWORK SERVICE user.

Hope this helps someone out there. It took me a little while to find the fix for that last issue.
 

 
 
alphatrak

Bringing you the coding smackdown since '95

Twitter Updates

    follow me on Twitter

    Now Playing

    • StarCraft - PC

    Now Reading

    • Death Note
    • Ikigami: The Ultimate Limit
    • Infinite Game Universe: Mathematical Techniques
    • Microserfs by Douglas Coupland
    • Pro Android 2