Friday, June 26, 2009

Unload Web Site and WAP in Visual Studio

Inside Visual Studio many times people want to be able to unload a projects without having to completely close them…

Web Application Projects (WAPs)/ Class Libraries Unload

WAPs or Class Libraries unloading the project allows you to open the .csproj or .vbproj within an XML editor and modify the properties… This is by far the biggest reason why unloading WAPs, Class Libraries etc is used…  You can Unload most of the VS projects by Right Clicking on the project node and clicking “Unload Project” as shown below:

image

After Unloading the project looks as below and you can again Right Click on it to edit the project file.

image

Web Site Project Unload

Web site project on the other hand are different, firstly cause they do not have a project file and hence unloading them to edit the project file is not a motivation…  People still do want the ability to unload Web Site project and the scenario around it is that when you unload a project then on Solution build the unload project does not get built… This way if you are in middle of writing some code in that project and have existing errors then you can still unload it and continue with solution build…  Also Reloading the project will be faster than opening a closed project…  With that said if you Right Click on Web Site project you won’t find the “Unload Project” option… 

The right Click context menu is already very long for Web Site and as Unloading Web Site is not as common the command for “Unload Web Site” actually sits in the “Web Site” menu on top of Visual Studio as shown below:

image

After unloading the project you can then right click on the unavailable node (just like WAP above) and ask VS to “Reload Project”…

Also FYI unloading and reloading of project resets a lot of in memory objects associated with the project so in VS 2010 we explicitly load and unload WAP as well Web Site when you change your project’s target .NET framework version (e.g. move from 3.5 to 4.0)… This allows VS to hook in the correct intelligence, toolbox etc etc associated with the correct .NET Framework version…

Hope this small tip & trick  will help you…!!

2 comments:

Anonymous said...

thanks...it helps me...

Anonymous said...

Great job.
Your unload website project tutorial saved me from pulling out all my hair (lol).