"Common Language Runtime detected an invalid program." error
SGayet
Posts: 2
Hi All,
I encounter the following problem when using ANTS Performance Profiler 7.4 Professional.
I'm trying to profile a console application, developped using .NET 3.5. and VS2008.
The profiled application failed with an error :
Common Language Runtime detected an invalid program.
This application works fine when launched either standalone or under debugger.
Profiling works also if the debugging session is launched with options :
- Sample method-level timings.
- Method-level timings; only methods with source
- Method-level timings; all methods
But fails with the options :
- Line-level and method-level timings; only methods with source
- Line-level and method-level timings; all methods
Any help ?
Regards,
I encounter the following problem when using ANTS Performance Profiler 7.4 Professional.
I'm trying to profile a console application, developped using .NET 3.5. and VS2008.
The profiled application failed with an error :
Common Language Runtime detected an invalid program.
This application works fine when launched either standalone or under debugger.
Profiling works also if the debugging session is launched with options :
- Sample method-level timings.
- Method-level timings; only methods with source
- Method-level timings; all methods
But fails with the options :
- Line-level and method-level timings; only methods with source
- Line-level and method-level timings; all methods
Any help ?
Regards,
Comments
If so, can you first try profiling your application on another machine, just to eliminate something being corrupt on the first box?
If that doesn't help, then it's likely that the line level option is hitting a security problem or similar, so trying with the profiler running elevated (right click - run as administrator) is a good first step, as is turning off your antivirus temporarily.
If the problem persists then we'll most likely need to know more about your code and any 3rd party assemblies you may be using. You can contact us directly by mailing support@red-gate.com quoting F0069401 in the subject.
Redgate Software
I am experiencing the exact same issue. I tested with ANTS Profiler v4.last v5.last et v7.last, on two different machines, behavior is exactly the same.
My project is WinForm based, .Net 2.0, built using VS 20102, I am under Win XP.
What is really strange is that last time I profiled the same application (a few weeks ago on the same installation) I had no issue at all with my v5.last (which is my regular version). The source code was modified since then, of course, but we didn't add new library or made serious architecture modifications.
More precisely, the code where the exception now happen every time has not been changed for ages, and apart from using generics, I don't see anything particular here. I am pretty sure the call stack was the same last time I successfully profiled.
I tried to thing of what may have changed in my configuration, but I would tend to say nothing but automatic Windows Update stuff.
Could it be that an update to .Net, for instance, causes this issue?
Thanks in advance for your help, I need a way to profile my application with line details...
I guess it's feasible that a windows update /may/ have altered something - if you've not really changed the code much then it's definitely unusual as obviously the profiler hasn't change either.
One thing to check; are you using the AllowPartiallyTrustedCallers attribute anywhere in your solution? This has been known to cause problems with line level timing.
Redgate Software
Thanks for the quick reply. We don't use AllowPartiallyTrustedCallers attribute at all.
Well, I did one additional test: I restored an old project from an archive, dated September 24, 2012.
At that time we were still using VS2005, and for sure I was then able to profile this project.
I recompiled it (with VS2005) and tried to profile it with my good old ANTS v5 and guess what: I got the very same exception at the exact same place in the code (which indeed hasn't change)!
So: same code, same ANTS, VS version ruled out.. I think a windows update might be the root cause. I am now at .NET: 2.0.50727.3643
What should I do? Give you my project is of course not possible and creating a test project I can share may take some time...
Any idea?
I believe it's possible to uninstall updates but that's all a bit trial-and-error unless there aren't many in between now and when it last worked...
Redgate Software
Anyway, I found the nasty update: it is named: KB2742596 and it's the before last .NET Framework 2.0 Service Pack 2 critical update. I installed it around January 18, 2013.
To figure this out I first removed the 2 last updates of this kind (the last one was installed this week): everything went right (not even had to rebuild my solution): no exception during profiling. I reinstalled KB2742596: crash.
So, now at least I can work, but I have the feeling that this situation is not very stable: should I refuse any critical update from now on? Doesn't sound good.
Do you have any comment?
Is Red Gate planning to address this issue?
I'm guessing that the problem is down to a combination of that patch and your particular application- are you able to supply us your app or alternatively something simple that demonstrates the same problem?
Redgate Software
I am trying to narrow down the code that actually trigger the issue, but I did not succeed so far.
It is related to constructing an object that has a generic parameters, but I guess that the type actually used is relevant...
I'll keep you up to date.
My set up is a little different:
Visual Studio 2008 (been on VS 2008 since 2008 )
.NET 2.0.50727.5420
Win 7 x64
Profiler 7.4
Has there been any progress on resolving this?
Redgate Software
Top of Stack Trace looks like this
Code Looks like this
.Net 3.5 - Cannot switch to 4.0 yet because of various libraries
Problem exists if IIS or WEb Dev Server used.
Really need to sort this out as I need to profile this app
Thank you very much!
Thanks to your code snippet I have been able to reproduce my issue.
The tiny VS2010 project to be downloaded here: https://www.dropbox.com/s/6hj5h49zap6why7/TestProfilerCrash.zip exhibits exactly what I am facing with my main big project I cannot share:
1) Start profiling the application
2) Click [crash] button
3a) If KB2742596 is installed the application will crash 100% of the time with ANTS 4 and 5
3b) if KB2742596 is NOT installed, everything is fine
James: hopefully you now have something reproducible and could start looking at the issue and fix it.
Thanks in advance,
Best regards,
Sylvain
*EDIT*
- I do get the crash; but I don't have the relevant KB installed (probably as I'm on Windows 8) but either way we can hopefully work out the trigger.
Redgate Software
pdorey- I notice in that same page a potential workaround for the original vulnerability the KB resolves when the problem relates to web-applications. May be worth you checking over that to see if it helps? Obviously it won't make any difference with the winforms version.
Redgate Software
Redgate Software
Just wondering whether you made some progress during those last 2 weeks.
Thanks.
After 8.0 there'll be an 8.1 to tackle anything that comes up from wider usage of the initial release, and this issue is to be looked at then.
Redgate Software
Thank you for the update. Of course I think you understand that this does not exactly solve my issue
What are the short and long term solutions that could work for me?
1) Short term: should I ask my team to remove all updates back to a working state and refuse any new until 8.1 is out?
Or do you have a workaround? Such as a way to rewrite code, a patch or something?
2) Long term: I think I understand that my only option will be to purchase licenses for 8.1, am I right? Or are you planning to update previous versions too?
It's very unlikely that any change to the profiler would be made in previous versions, so you'd need to update to version 8, yes.
Redgate Software
I noticed you released ANTS 8.0, congratulation!
Could you let me know the road-map for 8.1? I would like to know when you plan to release it and whether it will contain a fix for our issue.
Thank you.
Currently this issue is indeed slated to be fixed in 8.1 - I don't have a precise lead time on 8.1 but it's in the order of a few weeks rather than a few months.
Unless anything disasterous happens, I'd hope this is indeed fixed soon.
Redgate Software
A little more information was discovered today though - it seems the problem can be triggered by something as simple as an empty try/catch block in the constructor for a generic. Other causes are using, lock or foreach statements.
Another workaround asides from turning off line-level may be to move the constructor code into it's own method, and call this from within the constructor. It seems in some scenarios that is enough to stop the problem happening.
Redgate Software
I am sorry to insist, but: when do you plan to release something that fixes this bug?
Thank you in advance.
Regards.
If you're still seeing it happen then you're probably running into something slightly different and we'd need a code-sample to investigate.
Redgate Software
Thank you, your latest build seems to be robust against this issue, this is good!
Thanks a lot.
Redgate Software
I spent some time evaluating your latest release (8.2).
While it doesn't crash anymore with our code and all latest .Net updates, we are unfortunately not going to upgrade from 4/5 to 8.2.
The reason is that is it incredibly slow to operate: while the performance decrease of the application under test seems to be slightly better than with 4/5, the 8.2 release is almost unusable: it takes ages to expand one line, or even to get the first method tree after a range has been selected.
And overall the Method Tree UI seems to be so "asynchronous" that its hard to understand what's happening: for instance: I select a range and wait for the tree to display.
Then I select another range: I can see that something is happening since CPU usage goes up, but there is no visual feedback on the tree. So I am confused about which range this current tree corresponds to. After some time, the tree is suddenly refreshed. Needless to say that if I am not patient enough and select another range before refreshing, or try to expand a line, or select another thread, things get worse and worse.
Our computers are not super fast, ok, but we never had these kind of issues with 4 or 5: the UI is responsive and the time for getting the whole tree after selecting a range is reasonable.
I have to say I am disappointed by this: I was expecting some great improvements when comparing 8 to 4, but it's not the case: the usability is so bad that I don't want to spend more time exploring potentially new great features.
I am sorry for this bad comment. But we are not going to upgrade our versions as long as global performances of the UI are not improved.
This means that in order to solve the crash issue, I spent some time rewriting all code parts that are crashing version 4/5, based on your May 16 comment, so thanks a lot for providing these insight.
Again, sorry for this bad comment. We all love ANTS Profiler concept and reliability but I don't know what happened in between version 5 and 8 to render it unusable on our machines... Hopefully you are aware of this issue and will fix it at some points.
Best regards.