4

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.

Nil Pun
  • 17,035
  • 39
  • 172
  • 294
  • Can you provide the full stack trace and maybe provide the part of your code that causes this error? Are you sure your setup is identical for both servers? Do they both have the same application pools and everything that goes with it? Also, refer to this: https://connect.microsoft.com/VisualStudio/feedback/details/587594 – Styxxy Aug 28 '12 at 11:26
  • I've updated with full stack trace. It's plain out of box MVC 3.0 application. This error get shown when trying to access any pages. Yes AppPool are identical. – Nil Pun Aug 28 '12 at 11:37
  • What are your IIS settings for the project? Look for any differences in setup. – Styxxy Aug 28 '12 at 11:38
  • This exception usually is caused by invalid IL instructions, do you use IoC, ORM or any other framework that generate dynamic methods or classes at runtime? – Marcelo De Zen Aug 28 '12 at 11:39
  • We got Unity IOC for dependency injection and EF ORM. However, it works on one server but no other. – Nil Pun Aug 28 '12 at 11:41
  • @Styxxy which IIS settings should I look for as there seems be many in IIS7. – Nil Pun Aug 28 '12 at 11:42
  • Are you sure the server is running .Net 4.0 and not .Net 4.5. I have had issues upgrading 4.0 => 4.5 with exactly the same errors, I had to uninstall .Net 4.5 and reinstall 4.0, I am still trying to solve the underlying problem. – AlexC Aug 28 '12 at 11:42
  • Application pool, trust level, ... And also what AlexC says, are you sure it is running .NET 4.0 . – Styxxy Aug 28 '12 at 11:45
  • 100% sure the App Pool is runing under 4.0. Does it require server reboot after 4.0 Framework installation? And also do we need to install MVC3.0 framework on web server? – Nil Pun Aug 28 '12 at 11:46
  • Guessing: You may have some older version of one of those frameworks installed in the GAC. I would check the MVC3 assemblies on the problematic server since the problem seems to be on a MVC handler. If MVC3 Assemblies are ok, check the Unity assemblies. – Marcelo De Zen Aug 28 '12 at 11:48
  • Remove System.Web.MVC 2.0.0.0 from %WINDIR%\assembly ? Doesn't IIS serves the MVC dll from bin folder of web project? – Nil Pun Aug 28 '12 at 11:57
  • @Myagdi, I guess guessing is not working :\ See my answer and try that, so we can something to work with... – Marcelo De Zen Aug 28 '12 at 12:18
  • If the assembly (same version and culture) is installed in the GAC the local assembly is ignored. It's not possible to override the assemblies installed in the GAC, because otherwise this would be a security role. – Marcelo De Zen Aug 28 '12 at 12:19
  • Does .net framework installation requires a reboot? I did a googling, some says yes and few no. – Nil Pun Aug 28 '12 at 12:30
  • Usually does not requires a reboot, in win8 install the framework does not require a reboot. But I don't think this is a .net framework version problem but 3rd party frameworks (probably MVC3 or Unity) – Marcelo De Zen Aug 28 '12 at 12:36

2 Answers2

4

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).

Marcelo De Zen
  • 9,439
  • 3
  • 37
  • 50
  • thanks for answer. Why would same application work on one not other. Also did you want me to run peverify on all external dlls? – Nil Pun Aug 28 '12 at 12:29
  • It do not runs in this server because of versioning problem with some assembly. In the other server you do not get this problem because there all is fine and the correct versions are installed. Install RTM/Dev preview versions could cause this errors because the final version could change without change the assembly version. – Marcelo De Zen Aug 28 '12 at 12:31
  • Run peverify until you get a useful message from it. Start by the main assembly of the web application and then go for your other assemblies. Scan first the assemblies developed by you and then the 3rd party assemblies if necessary. – Marcelo De Zen Aug 28 '12 at 12:35
  • @devundef I used peverify and complained Unity dll, replaced it but did not solve the problem. BUT, thank you for you help very much appreciate it. – Nil Pun Aug 29 '12 at 11:50
  • @Myagdi, the app still not runs? You have to remove from GAC and reinstall the correct version. If you still get the same problem probably there are other problematic assemblies. – Marcelo De Zen Aug 29 '12 at 11:56
0

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

Arkaine55
  • 548
  • 6
  • 15