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;
        }
    }
}
gunr2171
  • 16,104
  • 25
  • 61
  • 88
MurtuzaB
  • 328
  • 4
  • 8
  • 2
    Have you tried this update? http://support.microsoft.com/kb/2748645 described in more detail here http://elegantcode.com/2012/08/23/net-4-5-operation-could-destabilize-the-runtime-yikes/ – hatchet - done with SOverflow May 15 '14 at 16:08
  • 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. – MurtuzaB May 15 '14 at 16:27
  • I was installing the wrong version. Issue Fixed. Thx a lot. – MurtuzaB May 15 '14 at 18:05
  • 2
    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? – Vu Nguyen Oct 03 '14 at 08:51

2 Answers2

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.

  • Is there a similar patch for .NET 4.0? – flipdoubt Aug 14 '14 at 19:02
  • 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. – Anthony Sep 24 '14 at 15:52
  • I installed 4.5.1 and the issue is gone. – Tony Oct 07 '14 at 09:04
  • 2
    I have the same issue, but am using Windows 8.1 which the fix doesn't apply. How can I solve it? thanks – Franva Jan 29 '15 at 00:35
  • 1
    I have similar exception with structuremap v3. I found that there is no exception if I use [structuremap v2 package](http://www.nuget.org/packages/structuremap/2.6.4.1). May be it because v3 has no strong name but v2 has. Hope this helps anyone. – hal Mar 26 '15 at 09:43
  • 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. – Dio Phung Jun 23 '16 at 19:03
  • The link no longer works, it returns a 404. Any workaround? – Brugner Dec 11 '19 at 12:50
  • 1
    @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. – hatchet - done with SOverflow Dec 11 '19 at 19:20
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.

Dio Phung
  • 5,944
  • 5
  • 37
  • 55