ASP.NET Web Site Project (WSP) vs Web Application Project (WAP)

ASP.NET 2.0 originally came without support for the ‘traditional’ Web Application project that everyone had become familiar with in ASP.NET 1/1.1.  Some people liked the new approach as it affords more ‘on-the-fly’ updates, but obviously enough people ‘didn’t’ for Microsoft to release a patch for Visual Studio .NET 2005 to allow creation of WAP’s.  The support was then formally re-added in VS 2005 SP1 (making the original patch redundant).


Info on the situation can be found here.


This post (as well as saving the links for me) is also a reminder of the limitations of the Web ‘Site’ model (hereafter known as WSP) and why I choose not to use it.



  • Namespaces.  WSP does not explicitly add a namespace to any page, class etc.  It uses ‘special folders’ with some implied names (e.g. App_Code) to determine the namespace hierarchy.  This whole situation can also lead to strange ‘circular reference’ errors with user controls – especially after converting from VS 2003.  At the very least you’ll be pulling your hair out wondering why you can’t reference some page or control from somewhere else in your site.
  • Code Reuse.  Only code in the App_Code folder (and below) can actually be referenced by another class in the project.  This forces a structure that you wouldn’t otherwise choose.  You can of course create separate assemblies – and should in many cases.
  • Unit Testing support in VS 2005.  WSP does not build to a single assembly when built in VS 2005, and must be ‘precompiled’ using a Web Deployment Project which in turn uses the asp_merge (publish) utility in order to achieve this.  The standard publish function doesn’t support a single assembly, although it’s possible to get the App_Code into a single DLL. This all means that because you don’t have an output at build time, you can’t run unit tests in the WSP – regardless of how much code you’re ‘reusing’ in the App_Code project.  You can jump through some hoops to call the NUnit Console runner, but why bother!?   
  • Included/Excluded files.  Because WSP doesn’t have the concept of a project file to say what’s ‘in’ and what’s ‘out’, VS 2005 uses a rather nasty ‘rename’ method of excluding files – simply suffixing the file with .exclude to denote it should be disregarded.
  • References are actually just copied in.  If you create a reference to an external assembly, VS 2005 will actually just copy the file into your bin folder.  This means you’ll end up putting all sorts of binaries in your source tree (under source control), that you maybe otherwise wouldn’t
  • Automated Build.  NAnt and other automated build tools can’t work out whether a Web Site project is some sort of ‘enterprise template’ project, or a tub of lard – because it’s not really a project.  This means that you can’t use the <solution> task with NAnt.  you have to call a custom <exec> task instead, calling the asp_merge.exe tool, then call all other projects separately too.  This all works, but again, why bother?  A cynic might conclude MS was trying to cause issues for NAnt, whilst getting people interested in MSBuild.

For me, any change that introduces new ‘non-standard’ tools, just so you can have the convenience of ‘on-the-fly’ updates just isn’t worth it.  You’ll actually find that this all goes out the window when you deploy to a server anyway, because depending on how you ran asp_merge, you probably won’t be able to do any ‘real’ updates because the assembly names are generated in that process and you’ll break the site by changing source files.  In my opinion if you are using this approach then use the Web Deployment project and build to a single assembly to minimse these issues.  If you’ve got any sort of structure around your production deployments (and you can’t just ‘copy over’) then I see literally no advantage in the WSP model, as it just seems to provide too much pain for no visible gain.

VB.NET – I know I shouldn’t care but I just don’t like it!

Aaargh! I thought to myself for the umpteenth time as I looked through my inherited VB.NET web site (it’s bad enough that it was a web ‘site’ with dodgy auto-generated (i.e. NO) namespaces), but the following things are now officially going on my list of reasons I choose C# over VB.NET.  I know I shouldn’t care as it all compiles to the same thing, but (just from this project) –



  • VB.NET still allows you to dodge the Option Strict and Option Explicit (definitely a ‘Web Site’, as there’s no option in the property pages like for any other standard .NET project).  This means that you happily declare untyped variables, and do all sorts of dodgy late binding.  Some people obviously like this facility, but it’s one of the things that holds VB programmers back in the world of object-oriented design.
  • Modules still exist!  OK you could argue this is just a public class with everything marked as static, but it’s still ‘global’, and you don’t need to reference the module name when you access a method or variable.  This often leads to the ‘where the hell is that defined?’ question
  • Variants still exist.  This is obviously an extension of the first one, but it’s a big enough annoyance that people use to get themselves out of a (I don’t know how to implement this properly using object-oriented techniques) hole
  • Syntax ‘feel’ – e.g. Me vs this, and MyBase vs base – it feels a bit ‘Mickey Mouse’.
  • Verbose syntax causing RSI:

    • #Region “String Constant” vs #region whatever you like without having to put quotes around (C# regions can also be indented with the code unlike VB)
    • Global functions instead of operators like TryCast instead of ‘as’, CType instead of (Mytype)variable.  CStr, Cint etc still exist.  Not only is this more typing in many cases as you need to enter two or more parameters, it also feels like yet more ‘baggage’ from the bad old days, as you can still pass in your objects to generic ‘library’ functions rather than use methods on the object themselves (like ToString()).  Many VB programmers will lap this up because the language still allows them and they don’t have to learn something new.

  • Case insensitivity.  OK I’ll give you this one as it was one of the ‘speed’ things in VB6.  It does lead you back to the horrible pseudo-hungarian thing (for some people) though as you get naming conflicts with properties and variables if you follow the general pascal/camel C# standard (can’t remember whether there’s an option to switch that off though).  The alternative to the pseudo-hungarian notation is the _ prefix for class variables, but even that seems like too much of a concession.
  • Methods can still look like properties.  Call a method in VB without parameters and it will happily let you write MyMethod.  This just feels like inconsistency.
  • Tool support and productivity. 

    • VB.NET simply doesn’t have the same support in Visual Studio or refactoring addins (ReSharper’s only catching on to VB.NET now) This isn’t the language’s fault, but it’s easier to be more productive through tools with C#.  (I know this is improved with every release of VS).
    • The default VS 2005 refactoring capability (limited but present in some form) for C# is basically non-existent for VB.NET.  Maybe Microsoft think VB programmers don’t need refactoring support?
    • Intellisense is also generally rather lacking for VB.NET
    • XML Documentation comments (just now catching up, but was really lacking)

  • Angle brackets <> look uglier than square brackets [] for attributes (OK that’s a bit picky!)

The bottom line is that VB.NET lets you be sloppy, like VB always did.  The problem is that a fair percentage of those who migrate from VB to VB.NET (not all I agree – don’t shoot me!) take the same shortcuts that they always did – because they still can.  


My opinion is that on average you’ll find more elegant design, better formatted and more object-oriented code from C# programmers as they’re more likely to have come from a C++ or Java background.


Did I mention that I was a VB programmer for years, and have only dabbled a bit in Java and not really ever C++.  I loved VB6 (at the time) as I could get systems written quickly and well.  What I didn’t love was how much backwards-compatible support it kept leaving in with each new version, just so people could upgrade their crap legacy code.  I’ve seen some very clear, consistent, well formatted and commented VB.NET code, but I’ve seen an awful lot more that’s not.  The flip side is that C# coders often think they’re great just because they’re writing in C#.  I’ve seen plenty of horror stories there too, but the ‘bad’ percentage is much lower (sorry – it just is).


VB unfortunately doesn’t encourage discipline in programmers, whereas C# benefits from a clean slate without the historical baggage.  I believe the slightly more formal language specification of C#, and the fact it attracts more ‘OO’ coders, tends to lead people to think a little more about design rather than just skipping straight to implementation (which is where the ‘real’ problem is 🙂 ).  You can write the same crap code in any language you like.  VB unfortunately just makes it easier.

Free Visual Studio 2005 Addins

I’m currently without ReSharper (eek), so am trying to make the best of it.  Looking around for VS 2005 addins (that I haven’t already got), I stumbled across a few resources….


Carl J has a list of Free Addins, and, wait – there’s another list


Not forgetting Hanselman’s (old) list


I’m sure there’s more, but I don’t want to overcapitalise and slow my machine down more than Resharper did (maybe I should look at CodeRush?)

Breaking Changes between .NET 1.1 and 2.0

I spotted an old post from Brad Abrams on breaking changes for .NET 1.1 apps recompiled with 2.0.  The links had moved but are still relevant…


http://msdn2.microsoft.com/en-au/netframework/Aa570326.aspx


My own observations from converting projects are a little higher level in that I’m also interested in what effort you’re liable for when converting, and also things to watch out for if (like me) you’re having to persist a ‘shared’ code base of 1.1 and 2.0 core libraries (temporarily) while you migrate all your client apps.


ASP.NET Projects.  This includes Web Service projects.  You’ll find that you’ll probably have to reconstruct these projects based on the content files and you’ll also need to make a decision on the model you’re going to use for debugging – i.e. whether to use the new debugging host (removing IIS from the debugging equation) and whether to use a dynamic or static port.  Steer clear of the ‘Web Site’ project too as this could leave you confused for hours wondering why you can’t debug anything – look for the ASP.NET projects.  More info on the ASP.NET side can be found from Peter Laudati’s post.  Microsoft also have an article covering conversion of ASP.NET projects


DataSets.  These have changed in that a ‘designer’ file is now the main source file (apart from the .xsd).  If you’re sharing DataSets across 1.1 and 2.0 projects just share the .xsd file otherwise you’ll be asking for trouble as the other generated files are incompatible.  Any structural changes to a DataSet in one project (say .NET 1.1) will not be reflected in the corresponding 2.0 project.  You’ll need to check out the XSD in both places (assuming you’re using VSS) and build both in order to avoid breaking one of the projects.


Windows Forms.  I’ve had a recent experience where the InitializeComponent() method in a form (edited with VS 2005) places calls that aren’t compatible with .NET 1.1.  The code compiles (as below) but ‘exception thrown by target of an invocation’ gets thrown on the following line…


((System.ComponentModel.ISupportInitialize)(this.validatingProgress)).BeginInit();


This is because the control (a PictureBox in this case) doesn’t implement ISupportInitialize in .NET 1.1 but does in 2.0.  The equivalent in 1.1 is SuspendLayout()


This would just be one example of something that’s syntactically correct, but could fail at runtime.


Visual Studio 2005 – Source Control Warnings (or lack thereof)

I’ve just had to apologise to my peers for breaking the build (thankfully not something that happens often).  I encountered an interesting situation where writeable files don’t show as such (a build script had ‘got latest’ but left files writeable).  I then made some changes and performed an incomplete checkin as half of the changed items weren’t checked out.  Visual Studio interestingly showed all of the files as ‘locked’ even though they were writeable.  VS2003 used to detect that and give you a different type of ‘tick’ to show the file was writeable but not checked out (I think 🙂 ).


‘Silly boy’ – I hear you cry – yes I should have done a get latest before checking in (but didn’t – my bad).  This does highlight however the Source Control settings available in the Tools–>Options dialog.  We enforce Checkin comments (through a VSS Addin) and so for safety (knowing what VS2005 is doing with VSS) it’s always worth ensuring the following are enforced:



  • Prompt before checkout
  • Prompt before checkin (to allow comments)
  • Don’t allow editing of checked-in items
  • Checked-in item behaviour

    • On Save – prompt for checkout
    • On Edit  – prompt for checkout

I’d changed some of these items in the past week but some had reverted to previous settings (a little concerning!!).


Anyway – it’s all good – the build passed and I’m a little wiser about what options to tick in future.

Visual Studio 2003 Colours – Registry Entries

Visual Studio 2003 doesn’t give you any way of exporting your customised colours (I’ve gone for a ‘black’ theme) – well, black is the new black you know!


The theme’s shown below (not that it’s that great – but illustrates the effect the registry entries (further below) have…  In Visual Studio 2005 of course you can simply export your entire settings.  Oh yeah – also ignore the code as that’s simply a work in progress for something I’m going to post on CodeProject in the next couple of months.



To create this look – simply copy the text below and save in a .reg file.  Take a backup of your current colours first of course by exporting the key: [HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\7.1\FontAndColors] to a file.  I’ve got some ReSharper v2 settings in there too so you can remove those if you don’t use ReSharper (shame on you!)


Windows Registry Editor Version 5.00


[HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\7.1\FontAndColors]
“Color Palette”=hex:ff,ff,ff,00,ff,ff,ff,00,ff,ff,ff,00,ff,ff,ff,00,ff,ff,ff,\
  00,ff,ff,ff,00,ff,ff,ff,00,ff,ff,ff,00,ff,ff,ff,00,ff,ff,ff,00,ff,ff,ff,00,\
  ff,ff,ff,00,ff,ff,ff,00,ff,ff,ff,00,ff,ff,ff,00,ff,ff,ff,00


[HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\7.1\FontAndColors\{A27B4E24-A735-4D1D-B8E7-9716E1E3D8E0}]
“Colorable item format version”=dword:00000008
“FontName”=”Monaco”
“FontPointSize”=dword:00000008
“FontCharSet”=dword:00000000
“Plain Text Foreground”=dword:00ffffff
“Plain Text Background”=dword:00000000
“Plain Text FontFlags”=dword:00000000
“Line Numbers Foreground”=dword:00c0c0c0
“Line Numbers Background”=dword:00000000
“Line Numbers FontFlags”=dword:80000000
“Collapsible Text Foreground”=dword:0000aaaa
“Collapsible Text Background”=dword:00000000
“Collapsible Text FontFlags”=dword:00000000
“Comment Foreground”=dword:002cef10
“Comment Background”=dword:02000000
“Comment FontFlags”=dword:00000000
“Current Statement Foreground”=dword:00000000
“Current Statement Background”=dword:0000ffff
“Current Statement FontFlags”=dword:00000000
“HTML Element Name Foreground”=dword:008080ff
“HTML Element Name Background”=dword:02000000
“HTML Element Name FontFlags”=dword:00000000
“HTML Operator Foreground”=dword:004080ff
“HTML Operator Background”=dword:02000000
“HTML Operator FontFlags”=dword:00000000
“HTML String Foreground”=dword:0000ff00
“HTML String Background”=dword:02000000
“HTML String FontFlags”=dword:00000000
“HTML Tag Delimiter Foreground”=dword:0000ffff
“HTML Tag Delimiter Background”=dword:02000000
“HTML Tag Delimiter FontFlags”=dword:00000000
“Identifier Foreground”=dword:00dfdfdf
“Identifier Background”=dword:02000000
“Identifier FontFlags”=dword:00000000
“Keyword Foreground”=dword:00538bff
“Keyword Background”=dword:02000000
“Keyword FontFlags”=dword:00000000
“Other Error Foreground”=dword:0000ff00
“Other Error Background”=dword:02000000
“Other Error FontFlags”=dword:00000000
“Preprocessor Keyword Foreground”=dword:00c0b4f3
“Preprocessor Keyword Background”=dword:02000000
“Preprocessor Keyword FontFlags”=dword:00000000
“ReSharper Completion Replacement Range Foreground”=dword:00e1e4ff
“ReSharper Completion Replacement Range Background”=dword:00000000
“ReSharper Completion Replacement Range FontFlags”=dword:00000000
“ReSharper Current Line Foreground”=dword:00ffffff
“ReSharper Current Line Background”=dword:00313131
“ReSharper Current Line FontFlags”=dword:00000000
“ReSharper Matched Brace Foreground”=dword:01000000
“ReSharper Matched Brace Background”=dword:00ffff00
“ReSharper Matched Brace FontFlags”=dword:00000000
“ReSharper Method Identifier Foreground”=dword:008b8b00
“ReSharper Method Identifier Background”=dword:01000001
“ReSharper Method Identifier FontFlags”=dword:00000000
“ReSharper Operator Identifier Foreground”=dword:008b8b00
“ReSharper Operator Identifier Background”=dword:01000001
“ReSharper Operator Identifier FontFlags”=dword:00000000
“ReSharper Read Usage Foreground”=dword:01000000
“ReSharper Read Usage Background”=dword:00face87
“ReSharper Read Usage FontFlags”=dword:00000000
“ReSharper Usage Foreground”=dword:01000000
“ReSharper Usage Background”=dword:00face87
“ReSharper Usage FontFlags”=dword:00000000
“ReSharper Write Usage Foreground”=dword:01000000
“ReSharper Write Usage Background”=dword:00c1b6ff
“ReSharper Write Usage FontFlags”=dword:00000000
“String Foreground”=dword:0034cb65
“String Background”=dword:02000000
“String FontFlags”=dword:00000000
“XML Doc Comment Foreground”=dword:002cef10
“XML Doc Comment Background”=dword:02000000
“XML Doc Comment FontFlags”=dword:00000000