5

We are recently upgraded a web/mvc application to use StrucutreMap 3.0.4

Now, when attempting to profile the application using RedGate Ant's profiler at the "Line Level Timings, All Methods with Source" or greater level, we get the following error

Operation could destabilize the runtime.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.Security.VerificationException: Operation could destabilize the runtime.

Source Error: 


Line 174:
Line 175:                            Initialise(context);
Line 176:                            ObjectFactory.Initialize(x => {     x.AddRegistry<BWebsiteIoc>(); });
Line 177:                        }
Line 178:                    }

Source File: c:\_Development\NT\Platform\WebSite\Global.asax.cs    Line: 176 

Stack Trace: 


[VerificationException: Operation could destabilize the runtime.]
StructureMap.ObjectFactory.Initialize(Action`1 action) in c:\BuildAgent\work\996e173a8ceccdca\src\StructureMap\ObjectFactory.cs:42
   Nga.Platform.Website.FirstRequestInitialisation.Initialise(HttpContext context) in   c:\_Development\NT\Platform\WebSite\Global.asax.cs:176
   Nga.Platform.Website.MvcApplication.Application_BeginRequest(Object source, EventArgs e) in c:\_Development\NT\Platform\WebSite\Global.asax.cs:106
   System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +182
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +165

I've tried adding to system.web in web.config as per http://documentation.red-gate.com/display/APP8/Operation+could+destabilize+the+runtime+error+profiling+ASP.NET

Dave
  • 1,068
  • 12
  • 26
  • Another solution to get rid of this exception, is to [add the assembly-in-concern to the "LineLevelBlacklist.xml" file](https://forums.red-gate.com/viewtopic.php?p=138072#p138072). – Uwe Keim Dec 26 '16 at 18:52

3 Answers3

4

May be an old question, but it's still one of the first for me on google results, so here goes.

I was able to solve the issue by deleting structuremap's pdb files before profiling.

Jay Otterbein
  • 948
  • 5
  • 10
2

Added <assemblyName>StructureMap</assemblyName> to %LOCALAPPDATA%\Red Gate\ANTS Performance Profiler 9\LineLevelBlacklist.xml which did the trick.

rickythefox
  • 6,601
  • 6
  • 40
  • 62
1

I was able to work around the problem by adding the following to the AssemblyInfo.cs of the class library causing the problem.

[assembly: System.Security.SecurityRules(System.Security.SecurityRuleSet.Level1)]

I found this solution in a Redgate forum discussion.