asp.netvisual-studio-2010

Compiling your website against a specific version of the .NET Framework


I don't have access to an IIS server but I am told that the site is configured to run with version 1.1 of the .NET Framework. When I use Telerik JustDecompile I see the following.

enter image description here

The "NET 1" seems to suggest that the 2 DLLs are compiled against version 1.1 of the FW. Does the "ANY" next to the website DLL "GLSS" indicate that the site can run against any version of the .NET FW that is installed on the web server?

In preparation for an upgrade to 2.0, I have asked the web admins to change the site configuration to version 2.0 of the FW and I was surprised that the site, which I considered to be running 1.1 code, still worked. Should I be surprised?

Is this just a simple example of backward compatibility and that the site could be configured to use any version of the framework provided that it was equal to or higher than the version that the code was compiled to use?

when I look at the property pages for the projects in the solution, I was surprised that, for the website project only, I was unable to locate where one sets the version of the FW which you want to compile against. I was able to locate it for the referenced projects.

How can I better understand the relationship between the version of the FW that a site is configured and the versions that the assemblies are compiled against?


Solution

  • You should not be surprised, .NET was always backward compatible in a sense that assemblies compiled against a version of the runtime are supposed to run against a newer version of the runtime.

    There are of course subtle issues where things are not backward compatible, starting from subtle semantic differences and ending with changes at the object contract level (where the expected method/class just does not exists anymore) but in general these problems depend on the complexity of your application. It is safe to assume that simple applications should just work with no issues.

    The number of the runtime the assembly has been complied against is a part of the assembly's metadata, it can be read with reflection. Thus, at runtime, you have at least two possible versions of the runtime - the one the assembly has been compiled against and the current version of the runtime which executes your code.