Is there a way to keep track of the number of CAS stacks that are happening?

I am working with a clock desktop application that uses p / invoke extensively and I want to make sure that the code does not spend a lot of time stacking in CAS.

I have used the SuppressUnmanagedCodeSecurity attribute where I think it is necessary, but I may have missed a few places. Does anyone know if there is a way to keep track of the number of CAS stacks that are happening and better yet identify the source of the security requirements?

+2


source to share


1 answer


You can use the Process Explorer tool (from Sysinternals) to monitor your process.

Bring up Process Explorer, select your process, and right-click to display Properties. Then, on the .NET tab, select the .NET CLR Security object to monitor. Process Explorer will show counters for

  • Total Runtime Checks
  • Checking connection time

  • % Time in RT checks
  • Pass stack depth

These are the standard security performance counters described here -> http://msdn.microsoft.com/en-us/library/adcbwb64.aspx



You can also use Perfmon or write your own code to monitor these counters.

As far as I can tell, the only thing that is really helpful is item 1. You can watch this while you debug to see if it increases significantly. If so, you need to investigate what is causing the security requirements.

I am not aware of any other tools that will tell you when stackwalk starts.

0


source







All Articles