.NET Framework Bookmark and Share   
 index > Building Development and Diagnostic Tools for .Net > when profiling apps with CLR Profiler v2.0 (from MSDN sample), always throw exception
 

when profiling apps with CLR Profiler v2.0 (from MSDN sample), always throw exception

i try to use CLR Profiler v2.0 sample from MSDN to profiling managed windows form apps , always throw exception.

exception text is:

See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.

************** Exception Text **************
System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
at WindowsApplication1.Form1.Form1_Load(Object sender, EventArgs e)
at System.Windows.Forms.Form.OnLoad(EventArgs e)
at System.Windows.Forms.Form.OnCreateControl()
at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl()

The profiler sample is from "No Code Can Hide from the Profiling API in the .NET Framework 2.0". I build the dll, then use command line to regsvr.

thanks!

dyna

I verified that I'm executing through FunctionEnterNaked2 without problems. My guess is we may be executing different versions of the runtime. If you'd like to probe deeper, here are a couple things you can do to help:

1) Get a full stack trace at the point of the exception, including all unmanaged code. You'll want to ensure your debugger is connecting to the Microsoft symbol server to ensure you're getting all the symbols for the runtime: http://msdl.microsoft.com/download/symbols.

2) Verify which versions of mscorwks.dll / mscordbc.dll are getting loaded. Using a debugger, detect the full path of the versions of those DLLs getting loaded, and check their version info in Windows Explorer.

Thanks for your help!

David Broman

Hello! I went to http://msdn.microsoft.com/msdnmag/issues/05/01/CLRProfilerand downloaded the profiler to try this out (please verify that's the same profiler you used). I then went to a command-prompt and did the following:

regsvr32 Profiler.dll

set COR_PROFILER={18884ADE-B15B-4af8-BE6C-FE5117BA4B32}

set COR_ENABLE_PROFILING=1

I then picked the first Windows Forms app I saw, which happened to be the profiler's Launcher.exe. So I just ran Launcher.exe from the command-prompt. So I was actually using the profiler to profile its own Launcher.exe tool, which isa little weird I know, but it was the first WindowsForms app I could find. (I didn't actually enter anything into the Launcher.exe UI, I just let it render its form and watched as the profiler did its logging). I verified that Profiler.dll got loaded as Launcher.exe executed and rendered its forms. But I never saw any exceptions. I wonder if I need to be running the particular Windows Forms app you were running? If you couldgive me more specifics about your scenario, I'll have a better chance of reproducing it here.

Thanks!

Dave

David Broman

Thanks Dave

I just unpack the CLR Profiler.rar, there is a compiled dll in debug folder. I use it in command prompt to profile a win forms app, no modification to the code. Then exception.

Then I compile the profiler to release version, (project file is converted from vs8 to vs9), still exception.

But i find the key maybe:

m_dwEventMask |= COR_PRF_MONITOR_ENTERLEAVE;
dwFooMask += COR_PRF_MONITOR_ENTERLEAVE;

When I delete EnterLeave mask, there's no exception. Maybe the reason is inline asm code for ENTERLEAVE function?

dyna

I verified that I'm executing through FunctionEnterNaked2 without problems. My guess is we may be executing different versions of the runtime. If you'd like to probe deeper, here are a couple things you can do to help:

1) Get a full stack trace at the point of the exception, including all unmanaged code. You'll want to ensure your debugger is connecting to the Microsoft symbol server to ensure you're getting all the symbols for the runtime: http://msdl.microsoft.com/download/symbols.

2) Verify which versions of mscorwks.dll / mscordbc.dll are getting loaded. Using a debugger, detect the full path of the versions of those DLLs getting loaded, and check their version info in Windows Explorer.

Thanks for your help!

David Broman
I have the exact same problem.

I went to the MSDN article on using the CLR profiler to profile the heap, and downloaded the exe zip file from the link in that article.

Then I ran the EXE to un-zip into the default location c:\clr profiler

Then I ran the profiler, and pointed it at my application, which is an XNA Framework v2 application.

The profiler starts the application, but the dialog saying "waiting for the application to start common language runtime" doesn't go away -- it doesn't appear to see that the application is starting.

When I quit my application I get the same exception from the profiler.

I am running Windows XP SP2, and I have both Visual Studio 2005 SP1 and Visual Studio 2008 installed, as well as XNA Game Studio 2 for Visual Studio Pro.



[code]See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.

************** Exception Text **************
System.NullReferenceException: Object reference not set to an instance of an object.
at CLRProfiler.Form1.checkProcessTimer_Tick(Object sender, EventArgs e)
at System.Windows.Forms.Timer.OnTick(EventArgs e)
at System.Windows.Forms.Timer.TimerNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)


************** Loaded Assemblies **************
mscorlib
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.1433 (REDBITS.050727-1400)
CodeBase: file:///C:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/mscorlib.dll
----------------------------------------
CLRProfiler
Assembly Version: 1.0.1395.16737
Win32 Version: 1.0.1395.16737
CodeBase: file:///C:/CLR%20Profiler/Binaries/CLRProfiler.exe
----------------------------------------
System.Windows.Forms
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.1433 (REDBITS.050727-1400)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Windows.Forms/2.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
----------------------------------------
System
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.1433 (REDBITS.050727-1400)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.dll
----------------------------------------
System.Drawing
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.1433 (REDBITS.050727-1400)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Drawing/2.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
----------------------------------------
System.Configuration
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.1433 (REDBITS.050727-1400)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Configuration/2.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll
----------------------------------------
System.Xml
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.1433 (REDBITS.050727-1400)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Xml/2.0.0.0__b77a5c561934e089/System.Xml.dll
----------------------------------------
[/code]

Jon Watte
I solved it. The download pointed at by that article is a 9 MB download called "CLR Profiler.exe," and has this problem.
If you search for "CLR profiler 2.0" and download the link for that particular product, you get a 5 MB download called "CLRProfiler.exe" (note the lack of a space), which works.

Jon Watte
Hi!

I was also receiving the CLR Profiler dialog "Waiting for the application to start common language runtime" and it would throw an exception every time in Windows Vista. Fixed it like this:

1. Make sure that you have the correct version of CLR Profiler (i.e. 2.x for .NET Framework 2.0).
2. CLR Profiler must be started with elevated (administrator) privileges (right click, Run as administrator).

The "
Waiting for the application..." dialog box should close immediately when starting your app (I don't even see it now).
DotNet_Ster

You can use google to search for other answers

Custom Search

More Threads

• Expanding the forum's scope
• Garbage collection synchronization problem
• IronPython output is missing
• Debugging Custom Attributes
• Sample app
• Is there any way i can create custom rules in fxcop 1.35 for region declaratives and summary (///summary) tag
• Identify the code block which consumes maximum time
• how to attach to debugger in-process
• Import statements fail in Studio 2008 but not in Studio 2005
• ICDType <-> MD Type signatures