简体   繁体   中英

“Operation could destabilize the runtime” when using ANTS profiler on a StructureMap application

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

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.

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 .

<assemblyName>StructureMap</assemblyName>%LOCALAPPDATA%\\Red Gate\\ANTS Performance Profiler 9\\LineLevelBlacklist.xml中。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM