Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

A website in IIS is set to use an Application Pool that is set to use .NET Framework Version 4.0. This website fails to load DLLs compiled with for 4.0. Pages on this website outputting the framework version (System.Environment.Version) report 2.0 loaded.

Why is this site loading the 2.0 framework? How can it be configured to load the 4.0 framework?

The application pool has been recycled.
Other websites on this box are loading and running the 4.0 framework.

share|improve this question
add comment

3 Answers

up vote 0 down vote accepted

Per Microsoft:

"The version of the .NET Framework that an application runs on is determined as follows:

"If the version of the .NET Framework that the application was built against is present on the computer, the application runs on that version."

Was the website compiled to target .NET 2.0?

To verify the framework version and CLR version that is targeted, there is a utility, corflags.exe, that you may use. For the bin folder where the assemblies are located, run the following command:

for %i in (*.exe,*.dll) do corflags.exe %i  

It will display, among other things, the .NET Framework version that the assembly is targeting. Note that you may also use corflags.exe to modify the PE header of the assemblies to target the .NET 4.0 CLR version, but you are probably better off recompiling for .NET 4.0 in Visual Studio.

How to: Use an Application Configuration File to Target a .NET Framework Version
http://msdn.microsoft.com/en-us/library/9w519wzk.aspx

supportedRuntime Element in app.config
http://msdn.microsoft.com/en-us/library/w4atty68.aspx

http://stackoverflow.com/questions/2961600/app-config-supportedruntime

Corflags information:
https://blogs.msdn.com/b/gauravseth/archive/2006/03/07/545104.aspx
http://msdn.microsoft.com/en-us/library/ms164699%28v=vs.80%29.aspx

share|improve this answer
add comment

Have you already checked the <compilation> directive under <system.web> in web.config?

share|improve this answer
add comment

Simply put, it dosn't work that way. Think of setting the app pool version as setting a default environment if nobody asks for anything else. If 2 apps are in a app pool and 1 uses 2.0 and 1 uses 4.0 it depends on who gets called first as to the version of the framework that runs in that app pool. The way that an admin can "fix" this (and you probably shouldn't since the app was likely targeted at 2.0) is by setting the supportedruntime in the application.config file (its under runtime) see< supportedRuntime> Element

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.