Images in this post missing? We recently lost them in a site migration. We're working to restore these as you read this. Should you need an image in an emergency, please contact us at imagehelp@codebetter.com
Speed Up VS 2005 Web Development - Kick your App_Code Habit

Scott Guthrie talks about how to speed up build times for Visual Studio 2005.. It's a great read, and definitely something to know inside and out if you're doing ASP.NET development with VS 2005. You've got to hand it to a person in his position doing down and dirty blog posts to help us little guys out, from what I hear and from recent personal experience, he's very accessible.

In his post about build performance, he actually has a good nugget of wisdom about overall performance of the IDE as well. He mentions this:

Keep the number of files in your /app_code directory small.  If you end up having a lot of class files within this directory, I'd recommend you instead add a separate class library project to your VS solution and move these classes within that instead since class library projects compile faster than compiling classes using the /app_code directory. 

This will speed build time, but will also speed up your design time experience as well.  Why you ask? 

I recently spent some time on the phone with Bradley Bartz from MS, who explained this very slowly and patiently to me. I hope he'll let me know if this isn't right, but from my understanding, Every time you make a change to a file in the App_Code directory, this invalidates the Visual Studio's internal cache of classes in this folder. The very next time you try to open a designer for an ASPX page or ASCX control, VS has to re-compile this folder to get the metadata it needs for the design-time rendering of the control. This can cause the IDE to slow to a crawl.  One the classes are cached, things speed up significantly in the IDE.

This was a big eye opener for me.  I'd been using the App_Code folder as an easy way to get a globally accessible class in my web projects. If it was stuff that only was related to the current web site, I felt this was a good choice for where to put the code.  The problem was, I was banging up against this slowness all the time. I'd get some class designed, tab over to a page or control to do some databinding and find myself waiting in frustration, my development rhythm shot. Little did I know that I was waiting on a compilation of the entire App_Code folder. 

So, I'm going to seriously wean myself off of this folder, in favor of a separate dll project for these situations where I need a class to be visible across controls or pages.

-Brendan


Posted 09-22-2006 1:28 PM by Brendan Tompkins
Filed under: ,

[Advertisement]

Comments

Billy McCafferty wrote re: Speed Up VS 2005 Web Development - Kick your App_Code Habit
on 09-22-2006 5:35 PM

Great find Brendan...I've gotten so frustrated with web project builds that I only do it about once a week or whenever I add a new PageMethods method (even then, you can update PageList.xml manually).  (IMO, App_Code was a terrible thing to give developers for a number of reasons...some of which you touched on above.)  Between the tips listed in the article, and the latest 262 build of ReSharper, I'm (cautiously) optimistic about developing with VS.NET 2005.

Dave Bouwman wrote re: Speed Up VS 2005 Web Development - Kick your App_Code Habit
on 09-23-2006 8:33 PM

Any idea if there is a similar issue with user controls in WinForms apps? I've got one small app that has about 10 user controls, and it's a total dog in VS2005, but other apps which don't have as many or any user controls are reasonable.

Thanks for the article - I've googled on this and found relatively little.

Christopher Bennage wrote re: Speed Up VS 2005 Web Development - Kick your App_Code Habit
on 09-24-2006 12:53 AM

I have a large Web application that started out in .NET 1.1.  When we migrated to 2.0 (and VS 2005) compile times grew significantly , as well as the time it took for the designer to open.  Based on Scott's blog, I converted the application to a Web Application Project.  (See http://webproject.scottgu.com/)  This helped a lot with the compile time, though I still have problems with the designer. I haven't performed any experiments, but I suspect it may have something to do with the inordinate amount of custom controls involved in the project.

Dave Donaldson wrote re: Speed Up VS 2005 Web Development - Kick your App_Code Habit
on 09-24-2006 6:05 PM

+1 for the Web Application Project. Using this instead of a Web Site project *greatly* sped up build times in VS2005.

Joe Niland wrote re: Speed Up VS 2005 Web Development - Kick your App_Code Habit
on 09-26-2006 5:53 AM

I've also found the Web Application Project to be superior. Unfortunately I am also experiencing very slow performance when using the designer! In the current project I'm working on, we're not using app_code at all, having opted for the separate class library approach.

In order to handle global constants in the web tier, we've created a 'Web' class library separate from the Web UI project (the web app proejct). Web contains the global.asax.cs code-behind file and a constants file, which can be used across the Web tier.

Namespace wise we have:

Company.App.WebUI

referencing:

Company.App.Web

which contains:

the classes: Global (global.asax.cs) and Constants

In the master page within WebUI, we reference the Web namespace, thus giving all WebUI pages access to Global and Constants.

Brendan Tompkins wrote re: Speed Up VS 2005 Web Development - Kick your App_Code Habit
on 09-26-2006 9:12 AM

Joe,

This sounds like it couldn't get any simpler.   Like I said, beta 1 is supposed to fix many of the IDEs "Papercuts" that make it slow.

I'm looking forward to it.

Chris wrote re: Speed Up VS 2005 Web Development - Kick your App_Code Habit
on 10-24-2006 11:20 AM

Should this only be done for older VS2003 sites? I did this for my web application that I started in VS2005 and while it does build much quicker it seems that a re-build will always cause my session to end. Will this change the way I update my site now because it looks like it compiles one site-wide dll? Am I missing something?

Thanks for the cool post!

Shannon wrote re: Speed Up VS 2005 Web Development - Kick your App_Code Habit
on 07-20-2007 7:27 AM

This is very interesting, and I can't believe I hadn't figured it out sooner..  Reminds me of a project I had a while ago which was an absolute dog, this would have helped so much.

PS. I look forward to the day when we can somehow stop blog spamming, that's just ridiculous and really destroys the experience.

Scott’s Blog » App_Code: Best In (Very) Small Doses wrote Scott’s Blog » App_Code: Best In (Very) Small Doses
on 11-06-2007 3:30 PM

Pingback from  Scott’s Blog » App_Code: Best In (Very) Small Doses

http://devlicio.us/blogs/brendantompkins/archive/2006/09/22/Speed-Up-VS-2005-Web-Development-_2D00_-Kick-your-App_5F00_Code-Habit.aspx wrote http://devlicio.us/blogs/brendantompkins/archive/2006/09/22/Speed-Up-VS-2005-Web-Development-_2D00_-Kick-your-App_5F00_Code-Habit.aspx
on 04-04-2008 9:25 AM
Ali wrote re: Speed Up VS 2005 Web Development - Kick your App_Code Habit
on 10-27-2008 4:43 AM

Hide the folders using windows explorer like App_Code, Images etc that u dont want to recompile again and again.

this will decrease the build time.

buy viagra online wrote re: Speed Up VS 2005 Web Development - Kick your App_Code Habit
on 02-02-2013 4:38 PM

RxSqOb Looking forward to reading more. Great article.Really thank you! Much obliged.

buy viagra online wrote re: Speed Up VS 2005 Web Development - Kick your App_Code Habit
on 02-02-2013 5:25 PM

7CfgRX Thanks for sharing, this is a fantastic post.Really looking forward to read more. Much obliged.

buy stendra online wrote re: Speed Up VS 2005 Web Development - Kick your App_Code Habit
on 02-15-2013 4:54 PM

PVkDpP Appreciate you sharing, great article. Great.

buy imitrex wrote re: Speed Up VS 2005 Web Development - Kick your App_Code Habit
on 02-23-2013 9:37 PM

MTg05B Thanks for sharing, this is a fantastic blog article.Really thank you! Want more.

buy imitrex online wrote re: Speed Up VS 2005 Web Development - Kick your App_Code Habit
on 02-24-2013 12:57 AM

b5MId7 I value the article.Really looking forward to read more. Much obliged.

http://1buyviagrahere.com/ wrote re: Speed Up VS 2005 Web Development - Kick your App_Code Habit
on 03-03-2013 2:46 AM

4jHhOx Really enjoyed this blog post.Really thank you!

amazing site wrote re: Speed Up VS 2005 Web Development - Kick your App_Code Habit
on 03-03-2013 10:39 PM

le2gzq I loved your blog article.Really thank you! Keep writing.

social bookmarks wrote re: Speed Up VS 2005 Web Development - Kick your App_Code Habit
on 03-13-2013 2:57 PM

68QbLC Appreciate you sharing, great article post.Much thanks again. Much obliged.

bookmaring service wrote re: Speed Up VS 2005 Web Development - Kick your App_Code Habit
on 03-14-2013 1:46 PM

y4ItGi Thank you ever so for you blog post.Thanks Again. Really Cool.

bookmaring service wrote re: Speed Up VS 2005 Web Development - Kick your App_Code Habit
on 03-15-2013 7:44 AM

bDIKs7 Great, thanks for sharing this post. Awesome.

Social bookmarks wrote re: Speed Up VS 2005 Web Development - Kick your App_Code Habit
on 03-24-2013 12:12 PM

6spTPO Hey, thanks for the blog article. Fantastic.

Social bookmarks wrote re: Speed Up VS 2005 Web Development - Kick your App_Code Habit
on 04-03-2013 11:01 AM

gbMV76 Appreciate you sharing, great blog article.Really thank you! Awesome.

buy social bookmarks wrote re: Speed Up VS 2005 Web Development - Kick your App_Code Habit
on 04-04-2013 3:40 AM

EnzfVD Thanks for sharing, this is a fantastic post.Thanks Again. Want more.

grizzly bears wrote re: Speed Up VS 2005 Web Development - Kick your App_Code Habit
on 04-05-2013 4:48 PM

I really like and appreciate your blog post.Really looking forward to read more. Really Cool.

bears wrote re: Speed Up VS 2005 Web Development - Kick your App_Code Habit
on 04-06-2013 3:19 AM

Muchos Gracias for your blog article.Really looking forward to read more. Fantastic.

buy social bookmarks wrote re: Speed Up VS 2005 Web Development - Kick your App_Code Habit
on 04-07-2013 7:33 PM

akHjU1 wow, awesome blog. Much obliged.

social bookmarking service wrote re: Speed Up VS 2005 Web Development - Kick your App_Code Habit
on 04-12-2013 10:33 AM

nLvmV2 Appreciate you sharing, great blog post.Much thanks again. Great.

cheap social bookmarks wrote re: Speed Up VS 2005 Web Development - Kick your App_Code Habit
on 06-19-2013 4:39 PM

aY4KHR A big thank you for your blog.Really looking forward to read more. Cool.

news and many more wrote re: Speed Up VS 2005 Web Development - Kick your App_Code Habit
on 07-04-2013 10:49 AM

qwFGJj Im thankful for the post. Really Cool.

visit this site wrote re: Speed Up VS 2005 Web Development - Kick your App_Code Habit
on 07-23-2013 7:21 PM

Appreciate you sharing, great blog article.Really thank you! Keep writing.

buy cialis online cheap wrote re: Speed Up VS 2005 Web Development - Kick your App_Code Habit
on 07-24-2013 9:10 PM

Thanks for the article.Thanks Again. Great.

best news on earth wrote re: Speed Up VS 2005 Web Development - Kick your App_Code Habit
on 07-26-2013 9:09 AM

bjDeie Very informative blog.Thanks Again. Fantastic.

best news wrote re: Speed Up VS 2005 Web Development - Kick your App_Code Habit
on 08-01-2013 4:28 AM

IYRRqC Fantastic post. Great.

stunning seo guys wrote re: Speed Up VS 2005 Web Development - Kick your App_Code Habit
on 01-08-2014 12:57 AM

uHuYN8 Fantastic blog post.Much thanks again. Great.

nice seo guys wrote re: Speed Up VS 2005 Web Development - Kick your App_Code Habit
on 01-15-2014 9:36 PM

QukEmC Im obliged for the blog post. Fantastic.

john wrote re: Speed Up VS 2005 Web Development - Kick your App_Code Habit
on 03-06-2014 12:04 PM
check it out wrote re: Speed Up VS 2005 Web Development - Kick your App_Code Habit
on 03-22-2014 12:23 PM

GGFb3m Major thankies for the blog post.Much thanks again. Keep writing.

stunning service wrote re: Speed Up VS 2005 Web Development - Kick your App_Code Habit
on 03-25-2014 8:32 AM

OWMwOZ This is one awesome blog article.Really looking forward to read more. Really Cool.

nice seo guys wrote re: Speed Up VS 2005 Web Development - Kick your App_Code Habit
on 03-25-2014 11:55 PM

H3Mbvr Appreciate you sharing, great blog post.Much thanks again. Awesome.

check it out wrote re: Speed Up VS 2005 Web Development - Kick your App_Code Habit
on 04-01-2014 5:50 AM

oyKMqV Thank you for your blog article.Thanks Again. Want more.

Galletto 1260 wrote re: Speed Up VS 2005 Web Development - Kick your App_Code Habit
on 04-08-2014 1:44 AM

Most non-hybrid full-size pickup truck fuel currently on the market is the Ram 1500 equipped with the 3.6-liter V6 and eight-speed automatic, which is rated at an EPA-estimated 17/25 mpg city / highway.

Add a Comment

(required)  
(optional)
(required)  
Remember Me?

About The CodeBetter.Com Blog Network
CodeBetter.Com FAQ

Our Mission

Advertisers should contact Brendan

Subscribe
Google Reader or Homepage

del.icio.us CodeBetter.com Latest Items
Add to My Yahoo!
Subscribe with Bloglines
Subscribe in NewsGator Online
Subscribe with myFeedster
Add to My AOL
Furl CodeBetter.com Latest Items
Subscribe in Rojo

Member Projects
DimeCasts.Net - Derik Whittaker

Friends of Devlicio.us
Red-Gate Tools For SQL and .NET

NDepend

SlickEdit
 
SmartInspect .NET Logging
NGEDIT: ViEmu and Codekana
LiteAccounting.Com
DevExpress
Fixx
NHibernate Profiler
Unfuddle
Balsamiq Mockups
Scrumy
JetBrains - ReSharper
Umbraco
NServiceBus
RavenDb
Web Sequence Diagrams
Ducksboard<-- NEW Friend!

 



Site Copyright © 2007 CodeBetter.Com
Content Copyright Individual Bloggers

 

Community Server (Commercial Edition)