We are moving our ASP.NET product from the .NET Framework 3.5 to 4.5.1 as part of this, our customers will need to change their application pool from CLR version 2.0 to 4.0.
The vast majority of our customers install using MSI, which correctly configures the application pool. Sometimes we have clients who manually configure their application pools for the application. We want to tell them: “Hey, you have the wrong CLR version selected in the application pool” using the product itself.
We have achieved something similar for the pipeline regime. We did this by creating an HttpModule that has a precondition integratedMode:
<system.webServer>
<modules>
<add preCondition="integratedMode" name="IisPipelineCheckModule" type="IisPiplineCheckModule, OurAssembly, Culture=neutral, PublicKeyToken=ba36f1f458df13fd" />
</modules>
All this HTTP module performs the output of an HTML page in which they are invited to change their AppPool to the classic pipeline (which we need):
application.Response.ClearContent();
application.Response.ContentType = "text/html";
application.Response.WriteFile(application.Server.MapPath("~/pipeline.htm"));
application.Response.End();
We tried to do something similar by adding a version precondition for version 2.0 to instruct clients to change the runtime version to 4.0:
<add preCondition="runtimeVersionv2.0" name="IisNetFxCheckModule" type="NetFxVersionCheckModule, SomeAssemblyCompiledFor20Clr, Culture=neutral, PublicKeyToken=ba36f1f458df13fd" />
Unfortunately, this has several problems. If AppPool is not installed correctly on CLR 2.0, it cannot even pass the parsing of web.config, because it can contain elements and attributes that are new to 4.0, for example <httpRuntime requestValidationMode="2.0" />. This will explode before it even gets close to executing the HttpModule. Similarly, if “bin” contains assemblies compiled for the 4.0 CLR, assembly load failures indicating that the assembly was created for a newer version of the runtime.
, , , , , CLR, - .config .
-, , ? , IIS 7.0 .