Operation could destabilize the runtime in StructureMap
Asked Answered
D

2

6

I am getting this error in one of my ASP.NET 4.5 MVC application on my local machine. Other applications setup with ASP.NET 4.5 and using StructureMap work fine. Error Message

Any help/solution on this would be highly appreciated. The line of code that causes this is:

using StructureMap;
using StructureMap.Graph;

namespace Management.Web.DependencyResolution
{
    public static class IoC
    {
        public static IContainer Initialize()
        {
            ObjectFactory.Initialize(x =>
            {
                x.Scan(scan =>
                {
                    scan.TheCallingAssembly();
                    scan.WithDefaultConventions();
                    scan.Assembly("Management.Core");
                    scan.Assembly("Management.DAL");
                    scan.Assembly("Management.BusinessServices");
                    scan.Assembly("Management.Infrastructure");
                });
                x.For<INavigationService>().Use<NavigationService>();
            });
            return ObjectFactory.Container;
        }
    }
}
Dincolo answered 15/5, 2014 at 15:53 Comment(4)
Have you tried this update? support.microsoft.com/kb/2748645 described in more detail here elegantcode.com/2012/08/23/…Chorus
Yes I had. Got the following message : Software Update KB2748645 Installation Wizard does not apply, or is blocked by another condition on your computer. Please click the link below for more details.Dincolo
I was installing the wrong version. Issue Fixed. Thx a lot.Dincolo
Hello, I also got the following message : Software Update KB2748645 Installation Wizard does not apply, or is blocked by another condition on your computer. Please click the link below for more details. I tried on both x86 and x64 but I got same error. How did you get over this, @MurtuzaB?Abominable
C
9

There is a .Net update that fixes this issue. KnowledgeBase 2748645

When you use some third-party controls, you may receive a System.Security.VerificationException exception. This issue occurs if the following conditions are true:

The third-party controls use the generic types.

The CLR verifier is enabled by declaring an assembly that is marked as security-transparent.

The issue is described in more detail in this blog post.

The problem exists on the IL level and is only detected when the CLR Verifier is executed on the code. The verifier makes sure that the IL is type safe before it’s sent to the JIT Compiler and if it detects and issue (like this) it will bark at you.

Chorus answered 15/5, 2014 at 18:10 Comment(8)
Is there a similar patch for .NET 4.0?Windsor
Is this fixed in version 4.5.1 or 4.5.2? I'd far rather update the framework on our servers to a supported version than install a hotfix.Amoebaean
I installed 4.5.1 and the issue is gone.Bromism
I have the same issue, but am using Windows 8.1 which the fix doesn't apply. How can I solve it? thanksSthilaire
I have similar exception with structuremap v3. I found that there is no exception if I use structuremap v2 package. May be it because v3 has no strong name but v2 has. Hope this helps anyone.Concession
For me, it happened because I ran ANTS 8 Performance Profiler for an ASP.NET MVC3 web. Once the profiler is disabled and de-attached, the error gone.Housekeeping
The link no longer works, it returns a 404. Any workaround?Soneson
@brugnner - Both links have gone away. The best I can do is change the links to point to the web archive, which I just edited into the answer.Chorus
H
0

KB2748645 does not apply for Windows 8/8.1/10. In this case, you can try : Run -> Turn Windows features on or off -> reinstall .NET Framework 4.5 & IIS .

Note: if you have ANTS 8.5 Performance Profiler, disable & de-attach it.

It helped in my case.

Housekeeping answered 23/6, 2016 at 17:34 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.