"Operation could destabilize the runtime" when using ANTS profiler on a StructureMap application
Asked Answered
S

3

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

Smock answered 18/7, 2014 at 21:58 Comment(1)
Another solution to get rid of this exception, is to add the assembly-in-concern to the "LineLevelBlacklist.xml" file.Proclivity
D
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.

Dwarfism answered 16/6, 2015 at 17:17 Comment(1)
Can confirm. Had the same error, deleted all files in bin folder, re-built. Job done.Boak
R
2

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

Ramonaramonda answered 29/3, 2018 at 21:19 Comment(0)
I
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.

Intro answered 25/10, 2016 at 11:42 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.