Exception -> Operation could destabilize the runtime

Code profiling for .NET Developers

Moderators: Luke Jefferson, StephenC, Alex.Davies, AndrewH, melvyn.harbour, Laura Morley

Exception -> Operation could destabilize the runtime

Postby cjlotz » Sun Jul 11, 2010 12:17 am

Hi

I've installed the new ANTS 6 Profiler after using the EAP successfully on and off during the last 2-3 months. We are using the new command line profiling features to get the profiler running in the background. We then use soapUI from the command line as well to create some load against our services. This gives us a sort-of-automated performance test run.

As mentioned, all of this was working at some point-in-time using one of the EAP builds. However, when following the same process using the RTW, we get the following exception:

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:


[No relevant source lines]


Source File: D:\\Projects\\VS 2008\\ninject.extensions.wcf\\source\\Ninject.Extensions.Wcf\\NinjectWcfApplication.cs Line: 0

Stack Trace:


[VerificationException: Operation could destabilize the runtime.]
Ninject.Extensions.Wcf.NinjectWcfApplication.Application_Start(Object sender, EventArgs e) in D:\\Projects\\VS 2008\\ninject.extensions.wcf\\source\\Ninject.Extensions.Wcf\\NinjectWcfApplication.cs:0

[HttpException (0x80004005): Operation could destabilize the runtime.]
System.Web.HttpApplicationFactory.EnsureAppStartCalledForIntegratedMode(HttpContext context, HttpApplication app) +587
System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +194
System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +352
System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +405
System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +368

[HttpException (0x80004005): Operation could destabilize the runtime.]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +646
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +141
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +771




--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.1


I've verified that we can successfully profile our application using the ANTS UI, so it seems to be related to profiling from the command line only. The problem also isn't related to soapUI as we use it just to create a load on the server. However, just to verify I also ran the profiler from the command line without using soapUI and got the same exception when browsing to the web site.

We are running directly against IIS and not using Cassini. Here is the command line we use for driving the profiler:

Code: Select all
"C:\\Program Files\\Red Gate\\ANTS Performance Profiler 6\\Profile.exe" /project:"D:\\PragmaDev\\OK52\\pOnKey\\Main\\Metrics\\PerformanceTests\\Pragma.OnKey5.app6" /verbose /lineLevel /onlyWithSource /force /timeout:60 /data:"D:\\PragmaDev\\OK52\\pOnKey\\Main\\Metrics\\PerformanceResults\\2010_07_11\\StaffMember\\00_53\\StaffMember.app6results" /htmlreport:"D:\\PragmaDev\\OK52\\pOnKey\\Main\\Metrics\\PerformanceResults\\2010_07_11\\StaffMember\\00_53\\StaffMember.Summary.html"


I tried looking in the logs folder, but the command line profiler doesn't seem to create any log entries. Can you please assist.

Thanks
Carel
cjlotz
 
Posts: 32
Joined: Sat Aug 08, 2009 6:21 am
Location: Cape Town, South Africa

Postby slaphead99 » Mon Jul 12, 2010 11:52 am

Yes- we'll get to the bottom of this one quickly, I'm sure. Were you able to send off an exception report to us? (If the dialog came up automatically).
slaphead99
 
Posts: 92
Joined: Wed Mar 10, 2010 2:27 pm

Postby cjlotz » Mon Jul 12, 2010 1:18 pm

Remember this only happens when running the profiler in command line mode and I get not exception dialog box popping up. Had a look in the log folder and the command line profiler didn't seem to write out anything there either. What additional info can I provide?
cjlotz
 
Posts: 32
Joined: Sat Aug 08, 2009 6:21 am
Location: Cape Town, South Africa

Postby slaphead99 » Mon Jul 12, 2010 7:46 pm

Could you get a mini-dump please and we'll analyze that here.
slaphead99
 
Posts: 92
Joined: Wed Mar 10, 2010 2:27 pm

Postby cjlotz » Tue Jul 13, 2010 5:32 am

Is there a link to an article somewhere that describes the process of creating a mini-dump?
cjlotz
 
Posts: 32
Joined: Sat Aug 08, 2009 6:21 am
Location: Cape Town, South Africa

Postby AndrewH » Tue Jul 13, 2010 10:40 am

This error generally happens because the line-level timings won't work when applied to partially trusted code. You can try adding an option to the command line parameters to turn this feature off, or you could temporarily change the assembly that's throwing the exception to be full-trust for profiling.

We're considering alternative ways of achieving the line-level support that will avoid this particular problem for v7.
Andrew Hunter
Software Developer
Red Gate Software Ltd.
AndrewH
 
Posts: 134
Joined: Thu Aug 17, 2006 3:44 pm

Postby cjlotz » Tue Jul 13, 2010 12:25 pm

Andrew

I can confirm that I don't get the exception when using the /methodLevel option on the command line. I would ideally like to have the line-level details via die command line profiler as well. Why does this work via the UI though? Shouldn't we hit the same problems?
cjlotz
 
Posts: 32
Joined: Sat Aug 08, 2009 6:21 am
Location: Cape Town, South Africa

Postby Brian Donahue » Thu May 12, 2011 10:26 am

It happens in the UI as well as the command-line. The settings must be different regarding the line-level timings.

I have a test case that demonstrates the problem - put a [System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.LinkDemand)] attribute on the Page_Load method of an ASPX codebehind file, set Web.Config to trust level="medium", and run it in the 4.0 version of development webserver and you wil see the error.

Change the profiler settings to use the "2.0" version of development webserver and there is no problem. Change web.config to trust level="Full" and there is no problem on either webserver.

The only way to make it work all-round at this time is to go through all methods in the application and take the SecurityPermission attributes off or do Code Access Policy the .NET 4.0 way.
Brian Donahue
 
Posts: 6670
Joined: Mon Aug 23, 2004 10:48 am

NInject with ANTS Profiler

Postby mhanrahan » Sat Jan 28, 2012 7:07 pm

When profiling an app that uses NInject I am getting an error that says "Operation could destabilize the runtime" if I use line level timings. As I have no control over this assembly I can't remove the security attributes. Is there any solution you could suggest to remedy this?

Thanks,

Mike.
Mike Hanrahan
mhanrahan
 
Posts: 5
Joined: Thu Jun 16, 2011 4:05 pm

Postby Brian Donahue » Mon Jan 30, 2012 10:03 am

Did you try setting web.config to Full Trust?
http://www.red-gate.com/supportcenter/c ... 0903000361
Brian Donahue
 
Posts: 6670
Joined: Mon Aug 23, 2004 10:48 am

NInject Issue Resolved

Postby mhanrahan » Mon Jan 30, 2012 3:49 pm

I was able to solve it by removing the NInject .pdb files and setting ANTS to only profile where code is available. Not ideal, but it will work until NInject remove the security policies that are causing this. Thanks.
Mike Hanrahan
mhanrahan
 
Posts: 5
Joined: Thu Jun 16, 2011 4:05 pm

Postby jessica.ramos » Fri Jun 29, 2012 11:26 pm

Another customer was able to resolve this issue by adding

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

to the assembly.cs file of the offending assemblies.
Jessica Ramos
Technical Support
Red Gate Software Ltd.
jessica.ramos
 
Posts: 235
Joined: Mon Apr 23, 2012 1:13 pm

Postby martinh_kentico » Thu Feb 21, 2013 7:05 pm

Hi, I can confirm that this helped also in our project:

[assembly: System.Security.SecurityRules(System.Security.SecurityRuleSet.Level1)]
martinh_kentico
 
Posts: 1
Joined: Thu Feb 21, 2013 6:49 pm


Return to ANTS Performance Profiler 6

Who is online

Users browsing this forum: No registered users and 1 guest