ASP.NET MVC 3 - Operation could destabilize the runtime

3.2k Views Asked by At

I've a MVC3.0 (.Net 4.0) application which runs perfectly fine on Windows 7 development machine (with VS2010). The same application also runs fine on one of the Windows 8 Server with IIS 7.

However, the very same application throws the exception below on other Windows 8 Server with IIS7.

Operation could destabilize the runtime.

Stack Trace:

[VerificationException: Operation could destabilize the runtime.] System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.BeginProcessRequest(HttpContext context, AsyncCallback cb, Object extraData) System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

Please, could someone help me to understand what is causing this issue?

Is it .NET Framework 4.0? (I verified both servers have .Net Framework 4.0 installed)

Is it IIS and MVC 3.0 Issue? (Do we need to install MVC 3.0 separately for IIS to run?)

How do we setup the web app to run on FULL TRUST in IIS 7?

Or completely something else (tried registering the iis with spnet_regiis.exe -ir did not help either)

Is it necessary to install this http://www.microsoft.com/en-us/download/details.aspx?id=1491 on web server?

Any help will be appreciated.

2

There are 2 best solutions below

0
On

The issue might be related to this hotfix: http://support.microsoft.com/kb/2748645

Based on your explanation of the issue and the tests you've already done, this framework bug sounds like it is the most likely culprit. Even though you are targeting .Net 4.0, .Net 4.5 replaces .Net 4.0 once installed.

Your Windows 7 machine with VS2010 probably does not have .Net 4.5, and therefore is uneffected by the bug.

The working Windows 8 server (which normally comes with .Net 4.5) may have been updated, and therefore already has this hotfix

So the non-working Windows 8 server probably has not been updated with this hotfix yet. (Running the normal Windows updates will eventually get this update as well)

You may want to compare the installed updates on both servers to ensure the environments match.

If you are going to be developing for machines that have .Net 4.5 installed, you want to consider switching to VS2012 or manually installing .Net 4.5 to mirror the changes. But be careful if you also target machines without .Net 4.5, there are other breaking changes...

Visual C# Breaking Changes in Visual Studio 2012

Application Compatibility in the .NET Framework 4.5

5
On

The VerificationException is thrown when the JIT compiler find mismatching type information in the assemblies or invalid IL instructions. For example, mismatching methods signatures (or return types) between callers and called method (when a method's signature is changed and the dependent assemblies are not recompiled).

To solve the problem you can use peverify to check the assemblies:

peverify MyCompany.WebAppMainAssembly.dll

It will tell what member is causing the conflict. Something like found <method sig>, expected <expected signature>. Now you know what assembly caused the problem. Reinstall it in the GAC if necessary. MVC, EF and Unity have msi installers, or install by hand...

BTW, to run the peverify open the Visual Studio Command Prompt or look for in C:\Program Files (x86)\Microsoft SDKs\Windows\<winver>\Bin (this path can change a bit).