Scott Forsyth's Blog

Postings on IIS, ASP.NET, SQL Server, Webfarms and general system admin.

Running multiple versions of the Framework in ASP.NET

Like any good technology, ASP.NET continues to evolve as new versions are released.  But, like anything else, this brings with it a number of considerations.

Microsoft has done a great job of allowing multiple versions of the framework to run side by side.  Version v1.0, v1.1 and v2.0 can all run together at the same time on the same server.  Each site, or even a vdir (Virtual Directory) within a site can have its own version of the framework installed.  Simply install the framework version on your server and it will be available to you.  The install itself is quite small, for example the v2.0 download is 22MB.

The Microsoft homepage for the .NET Framework is:
http://msdn.microsoft.com/netframework/downloads/updates/default.aspx

There are a couple gotchas to consider with running multiple versions of the framework side by side.  First, let's dig into IIS a bit.  Following is a snapshot of Windows Task Manager on an IIS5 (Windows 2000) server:

IIS5 screenshot

Notice the 3 processes called aspnet_wp.exe.  There is one per version of the framework. (v1.0, v1.1 and v2.0)  If a process for a particular version of the framework doesn't exist, as soon as it's needed, a new process will be spun up.  This allows multiple versions of the framework to live beside each other in IIS5.  No effort, no pain . . . it just works.

Now consider the following IIS6 (Windows Server 2003) screenshot:

IIS6 screenshot

Notice that there aren't any aspnet_wp.exe processes anymore, but there are w3wp.exe processes instead.  IIS6 was an impressive upgrade that brought with it some new concepts.  One key new concept is Application Pools.  A system administrator is able to create groups of sites and place each site in its own group.  Whenever a site needs to run, a w3wp.exe process will start for its application pool if it hasn't already started.  This brings with it a number of welcome security, performance and management advantages.  You are now able to specify your own Identity User which can be unique per Application Pool.

In IIS6, the aspnet_wp.exe process is done away with, and the work that it did is now done within each w3wp.exe process.  This has the same advantages I mentioned previously, but it has one big gotcha! 

You cannot run more than one version of the framework in the same application pool in IIS6.

While multiple versions of the framework can co-exist on the same server, they can't co-exist in the same process.  If you attempt to run multiple versions of the framework at the same time in the same process, the 2nd version that tries to run will fail with the following error:

Server Application Unavailable

The web application you are attempting to access on this web server is currently unavailable.  Please hit the "Refresh" button in your web browser to retry your request.

Administrator Note: An error message detailing the cause of this specific request failure can be found in the application event log of the web server. Please review this log entry to discover what caused this error to occur.

You will also receive Event ID 1062 in Event Viewer that says:

"It is not possible to run two different versions of ASP.NET in the same IIS process. Please use the IIS Administration Tool to reconfigure your server to run the application in a separate process."

What to do

Fortunately, the solution is easy enough.  Simply create a new application pool and move the site that you will be upgrading to that pool.  You can even base it off of the existing one if you don't have the password memorized for the existing one.  This is all done within IIS.  Once you have placed the site or vdir in its own application pool, then you are ready to upgrade to the new framework version.

I'll cover the different ways to move between different versions of the framework in another blog within the next few days, but the key thing to walk away with now is that multiple versions of the framework cannot co-exist in the same worker process at the same time.  IIS5 didn't have any issue with this, but IIS6 requires that each version be in its own app pool.



Posted: Jan 26 2006, 01:59 PM by OWScott | with 41 comment(s)
Filed under: ,

Comments

Ohad Israeli said:

Another problem you might get is the fusion process... if you are calling managed code from unmanaged process your managed process will be loaded with the latest version of the clr. you can add app.config to the unmanaged process where you'll declare the target version or use hosting clr api to direct to specific version of the clr but there are cases where this solution is just not enough.
# January 26, 2006 6:40 PM

Ryan Mrachek said:

Question: What considerations do you have to make to run a 1.1 application in a 2.0 site and how would you work security from the root?
The reason is that typically we run a few applications off the root, I've upgraded the root however since I previously taken off IsolateApps in 1.1 to share the authentication throughout the site the 1.1 application now sees the 2.0 web.config and blows up.
Suggestions?
# February 22, 2006 6:32 AM

Scott Forsyth said:

Hi Ryan,

That's a good question. Sometimes it's not even possible because new elements in the v2.0 web.config will always be read from the root and attempted to be applied in the v1.1 app. If they don't exist in v1.1, it will throw an error which, as far as I know, can't be avoided. This happens to a folder marked as an application and a vdir pointing to a different physical directory. If you run into that situation, you may need to put the v1.1 app in a completely different site, or make the v1.1 the root site and the v2.0 the vdir.

In the case of httpModules and httpHandlers and similar v1.1 features, they can be removed from the v1.1 web.config using <remove />. But you may need to put a skeleton dll in the v1.1 app to make it happy. I covered inheritance some more in this blog:

http://weblogs.asp.net/owscott/archive/2005/12/29/434181.aspx
# February 22, 2006 9:01 AM

Scott Forsyth's WebLog said:

Starting in the first version of ASP.NET, Microsoft has provided a tool to control which version of the...
# May 31, 2006 1:00 AM

Yaheya Quazi said:

We have a new issue which I think I have not found by searching the net as of yet. The issue is, if you run a dot net 2 app in the root of your web site such as (www.yourdomain.com) you can not have virtual directories that uses 1.1 version of the dot net framework. The other scenario works though where the root site uses 1.1 but the virtual directory uses 2.0. Is this by design? Can someone help please??

# September 12, 2006 4:21 PM

Yaheya Quazi said:

Ok, I finally used my support incident calls from my MSDN subscription to get to the bottom of this issue. At first the Microsoft support personnel who was helping me (case number SRX 060913602014) gave me hope that it is not an issue and it can be fixed. But after about 2 and half hour of trouble shooting the support personnel admitted that you can not have a dot net 2 application at the root of your web site and 1.1 apps as virtual directories from the same root.

The reason is, by design asp.net applicationsr has a file Hierarchy read more about it here http://msdn2.microsoft.com/en-us/library/ms178685.aspx (sent to me by the MSDN support personnel). So when you have a web.config file in the root of the web site that is in 2.0, and the virtual directories are in 1.1, it simply does not know how to handle the 1.1 web.config file.

So as you can imagine, after hours and days wasting in this issue, I am back to where I started. I am a die hard fan of Microsoft, however, lately I am just not so excited about their business practices. I feel they (Microsoft) is not being 100% honest with us.

One last thing, before I end my entry, the MSDN support person, sent me an email invitation to live meeting so she could look into the issue I was having. She sent it to my MSN account, and I use Windows live mail beta to read my emails. I was not getting her email and after 10/15 minutes, I looked in my junk mail folder of the live mail and found her email sitting there! Imagine, Microsoft live mail is filtering an email coming from Microsoft.com domain as junk mail!!! How funny is that!!

To conclude - You can not have an asp.net 2 app in the root of your web site if you have virtual directories that needs to be in 1.1 version.

Thank you.

# September 13, 2006 2:44 PM

Syed Raheel Noor said:

The article is great and to the point.

I have solved my problem after reading this article

Thanks Scott

Regards

Raheel

# September 14, 2006 1:37 AM

Leran said:

Yes, it helped me solving the problems. thanks.

# October 27, 2006 11:18 AM

Peter Larsen said:

This article (and the fact that I could find it on Google using the error message from Event Viewer) took me from absolutely clueless to problem solved in 15 minutes. Thanks!

# November 13, 2006 12:04 PM

Ravi said:

The article is good, it helped me to better understanding different versions of IIS...

Thanks a lot

# November 13, 2006 1:57 PM

Azola said:

Hi

I have 3 web applications, and all of them are .Net2. I created an Application Pool called Net2AppPool. Only 1 of them works. The other 2 give me the error:

"It is not possible to run two different versions of ASP.NET in the same IIS process. Please use the IIS Administration Tool to reconfigure your server to run the application in a separate process."

# November 14, 2006 6:39 AM

Ian Wermerling said:

I am trying to convince our company to move from 1.1 to 2.0.  Unfortnuately the guy in charge of the production server has it in his head that running multiple versions of the framework on a server will have a major performance hit on the server and it would put alot more stress on the actual server.

Is there any truth in this?

# November 24, 2006 5:53 AM

Travis Butcher said:

Thanks for the great little article.  I was not able to get my sites working properly until this.

# December 29, 2006 3:37 PM

Aref said:

I have created a new app pool and moved the application there. but I have still the error. event 1062

# January 6, 2007 1:21 AM

Tex said:

Worked fine for me... Thanks.

# January 11, 2007 7:33 AM

Juls said:

Thanks for this little tid-bit.  Worked awesome!

# January 13, 2007 12:44 PM

Chris said:

i created a new app pool for my 2.0 and THEN right-click app pool and Properties and Identity tab, then set the security account the same as my 1.1 - this solved all of my problems! (thanks, Alka!)

# January 24, 2007 10:56 AM

Joe said:

First off let me tell you I'm not experienced with IIS.  The most advanced thing I have done with it is an iisreset.  My problem deals specifically with a Windows 2003 Small Business Server and it seems to only affect 1  thing - Trying to download the Connection Manager from the Remote Web Workplace.

All of the Web Sites on this server are using ASP.NET 2.0 except for 1 - exchange-oma.  It appears that I have the ability to simply make it use version 2.0.  What could go wrong if I try to change it?

# January 24, 2007 2:59 PM

Kim Stroh said:

We have a 1.1 web site that was using SQL 2000 Reporting Services. We opened reporting using query params in a pop-up window. We upgraded to SQL 2005 and its version of Reporting Services (ASP.Net 2.0) and also upgraded our reports to VS2005. We now get this same error we sending in the url and trying to open the pop-up window. The vir dir for the main web site is 1.1 and the vir dirs for the reports and report server are 2.0. Is there a way to hit the new reporting services with ASP 1.1 code?

# January 24, 2007 4:35 PM

OWScott said:

Hi Ian,  Sorry for the long delay in replying.  I need to get the email notifications fixed so I can see when I receive comments here.  

v1.1 and v2.0 will run beside each other without any noticeable performance penalty.  There would be a slight performance penalty if you break a site into parts since there will be more AppDomains around which pre-load necessary .NET information.  But that would be negligible.  Multiple versions co-exist very well together.

# January 25, 2007 4:58 PM

OWScott said:

Hi Joe, just make sure to place it in its own app pool before doing the change.  Once you change it, you can put multiple sites in the same app pool, but you don't need to.  There is some memory overhead with each app pool but if you don't have many, and your RAM is good, leaving it in a separate app pool is probably best anyway.

Also, take note that using the ASPNET tab causes an AppDomain recycle on *all* sites on the server, even if you are just changing it for one site.  So be careful not to change it using that on a production server during prime time.

# January 25, 2007 5:01 PM

OWScott said:

Hi Kim,

SSRS sets up multiple virtual directories.  Setting up app pools is easy, so the best bet is to create a v1.1 app pool and v2.0 app pool.  Then just move your sites to the appropriate vdir.  

I haven't tested SSRS 2000 on v2.0 but my guess is that it would work.  You may be able to get away with upgrading all of your sites to v2.0, and then you don't need to worry about all about them fighting with each other.

# January 25, 2007 5:06 PM

David said:

What would the command be from the command prompt to change a sites ASP version from 1 to 2 or vice versa.  Would you use aspnet_regiis.exe -i (something goes here)?

# February 10, 2007 2:11 PM

Veeru said:

Thanks for the great little article.  I was not able to get my sites working properly until this.

# February 14, 2007 9:35 AM

HelenG said:

To say that running multiple versions will 'create a major performance hit on the server' is a huge  understatement. Our's was working just fine before, and now it slowed down to a crawl. And we are getting these error messages intermittanly. yak.

# February 15, 2007 2:29 PM

Rob said:

What about when you want 1.1 code to use a 2.0 component that is installed in the GAC?  How would you go about setting that up?

# March 13, 2007 7:48 PM

Ajay Goel said:

But can't Microsoft do the changes in IIS6 so that it cud also allow different versions of the framework to be  run at the same time in the same process??

# March 20, 2007 8:26 AM

Surya Prakash said:

Hi ,I am having a very strange problem.I am running the default site on .net 2.0 and have configured share point site on .net 1.1 but through different application pool.

While accessing this site,it is giving error ,You are not authourised to view this page

HTTP Error 403 - Forbidden: Access is denied.

Internet Information Services (IIS)

Can any body suggest me wht to do here.

# March 22, 2007 5:36 AM

radeis said:

Surya, I've been having the same issue on a hosted platform.  Even if i run separate app pools, i still get the same 403: Access denied.  Anyone have any thoughts on this?

Regards,

CJ

# March 25, 2007 10:39 PM

Jason Kelley said:

Check to make sure that both app pools are not using the same IP address.

# April 20, 2007 3:46 PM

BThomas said:

Thanks for this post. It is a life saver. I've searched and searched for an answer to this problem and this is the only one that makes sense and the one that worked.

The only thing I would suggest is adding a short instructional on how to add an application pool. I tell ya, ASP.Net is great but it sure doesn't come without road bumps.

# May 2, 2007 6:17 PM

Bjorn Tipling said:

Hi,

This article helped me! Thanks. The screenshots of the task manager were really helpful.

# May 7, 2007 1:14 PM

phoenix said:

I try to configure this website (quocanhiec.com.vn) but is still have this problem.

Please tell me how to create a new application pool and move the site to that pool. I have read this article http://msdn2.microsoft.com/en-us/library/ms998297.aspx

from MSDN and do like the guide but it still not work.

Plz.. help me! Thank

My email : ngock2c@yahoo.com

# May 13, 2007 7:26 AM

Tal said:

Hi ,I am having a very strange problem.I am running the default site in my company domain and everything working good. but when i'm tried to running the same site without the domain i'm received the following Error:

"HTTP Error 403 - Forbidden because SSL use is required"

Can any body suggest me what to do here.

I'm typing "https://" at the beginning of the address.

Regards,

Tal

# May 14, 2007 10:00 AM

Monty said:

> I'll cover the different ways to move between

> different versions of the framework in another

> blog within the next few days

Cool, can't wait!  ;-)

# May 31, 2007 5:57 AM

Monty said:

Very concise instructions to set up a separate App Pool are here:

www.irishdev.com/.../1027.aspx

# May 31, 2007 6:28 AM

Anas Bahsas said:

thanks scott I have solved my problem , my home directory using 1.1 and childs using 2.0 , but I have added new application pool for 2.0 vdir

# July 8, 2007 5:24 AM

adb said:

folks,

this is urgent

after doing all of this if try to browse to the url i get 404 resource not found.

what i am missing

# August 3, 2007 9:19 AM

OWScott said:

Well, I'm a few months late replying to some of these, but I'll give a quick reply now for anyone that happens to be reading the thread and comments.  Thanks to everyone that already answered some of the questions.

David: It's the -s command that you're looking for: aspnet_regiis.exe -s W3SVC/1/ROOT/SampleApp1.  The 1 needs to be replaced with the siteID.  The /SampleApp1 can be left off if you're setting the framework version for the whole site.  You can also do the same using the ASPNET tab, but understand that either aspnet_regiis and the ASPNET tab will cause appdomain recycles for the entire server!  So don't run this during prime time on a production box.  

That leads to my second comment, Monty I still need to write my blog post on the ASPNET tab.  I obviously didn't hit my deadline for that.  I'm trying to decide if I should clean up an internal script and make it public.  I'll be sure to get to this fairly soon.

Rob, I'm pretty sure that a v1.1 site can't run a v2.0 app that's in the GAC.  You'll probably need to upgrade your app to v2.0 for it to work.  The vast majority of v1.1 sites will run under v2.0 without any changes though, so give that a try and see if an upgrade works for you.  

Ajay Goel, I'm sure they can if they really tried, but the work to get multiple versions of the framework to load within the same worker process and play nice together is extensive.  It's probably cleaner all around to do it this way.  IIS 7 is cleaner yet.  You set the framework version at the app pool level rather than the application level, so it ensures that you'll never mess this up.

Surya Prakash, your error isn't caused by the framework mismatch, it's something else.  A 403 error can be from a large number of things, for example no default doc or not execute permission granted on the folder.  I suspect you've solved this months ago so I won't go into detail on this one now.

Tal, my best guess on yours is that you're using a different type of bit encryption level, or maybe a browser setting is not allowing you to view the page unless the domain name matches the cert, or some images or referenced objects in your page are referencing http:// without the https.

Adb, a common cause for a 404 error is if you are using a different file extension that isn't set as a valid MIME type of a file extension.  IIS6 will throw a 404 for that.  As a test, rename the file to a common extension like aspx and see if it works.  Or, the more obvious error is that the file doesn't exist.  :)

# September 6, 2007 12:50 AM