tags:

views:

72

answers:

3

I have an asp.net site that is using version 1.1 of the .NET framework. Occasionally, the site will begin crashing with an object null error and bring up an error screen that reports the .NET version as 2.0. If I recycle the site app pool, then the site will come back up and run normally until it crashes again a week or two later. If I manually change the .NET version to 2.0, then I get the same object null error.

Has anyone seen a problem like this before or know how to fix it?

A: 

Like Andrew Hare said in the comments, your app pool may be shared by a 2.0 app. Another option is you have a reference to a 2.0 dll in your web.config, and the app is just crashing when it hits that.

orthod0ks
A: 

As questioned by Andrew, you may be having a conflict between separate programs who share the app pool but run on different versions of the framework.

An application pool itself does not have a setting for which compiler/.net framework version to run. This is set by the compiler tab for the application that is running in the application pool and only one framework can be running in each pool.

If this is your case then it’s all about timing…. Since the application pools do not themselves drive what framework is used in them, the application does. The first application to start the application pool will set what the entire pool will run under for the .net framework since a pool can only run one framework.

If the pool is loaded/started by a 2.0 app then your 1.1 is crashing. You then have to stop the pool, restart and you immediately load the 1.1 app which causes the pool to run with the 1.1 framework.

To fix this conflict you can create separate app pools and assign applications to the pools.

You also have to be careful to ensure that the application's compiler tab is set properly and / or that the applications are put in the correct application pools.

For example, we have sometimes set it wrong and that created havoc. Check to see if you have any apps that are 1.1 but the compiler tab is set to 2.0 for them in IIS. That could definitely cause the issue if that app was the first to load the pool and may not cause an error for that app if the 1.1 code is all compatible with the 2.0 framework (and at least from my experience this is definitely possible).

Alternatively, see if other apps have accidentally been put into the pool with the app that is failing....

klabranche
I don't think this is my problem since I only have one app in the pool, but this is good advice nonetheless, I'd vote you up if I had the reputation.
Joe
Just come on back to this one when you do reputation and give me a point. :) I wrote a little manual on it for our team since we have several 1.1 and 2.0 app and app pools floating around on our servers. :)
klabranche
+1  A: 

Hmm - Scott Hanselman had an issue similar to this - it turned out that requests to non-.NET resources that are made after the application had timed out in IIS and been unloaded could cause it to start in 2.0 mode.

Adding the <supportedRuntime> element to the web.config resolved the issue:

<configuration>
  <startup>
    <supportedRuntime version="v1.1.4322"/>
  </startup>
</configuration>
Zhaph - Ben Duguid
This sounds good, I'll try that.
Joe