System.BadImageFormatException Wrong image format
Lasse
Posts: 1 New member
Hi, im using the latest version of the Performance Profiler (10.1.8.1426 pro).
I tryed to profile my ASP.net MVC version 4.7.2 application on IIS.
Since the latest update, this error message occured:
System.BadImageFormatException: Es wurde versucht, eine Datei mit einem falschen Format zu laden. (Ausnahme von HRESULT: 0x8007000B)
Log Errors:
I tryed to profile my ASP.net MVC version 4.7.2 application on IIS.
Since the latest update, this error message occured:
System.BadImageFormatException: Es wurde versucht, eine Datei mit einem falschen Format zu laden. (Ausnahme von HRESULT: 0x8007000B)
Log Errors:
28 Aug 2019 13:24:36.030 [21] ERROR RedGate.Profiler.Engine.Startup.IIS.IIS7Utilities - The profiler tried to run "C:\WINDOWS\system32\inetsrv\appcmd.exe list apppools " but got the error: "<?xml version="1.0" encoding="UTF-8"?>
<ERROR message="Konfigurationsfehler 
Dateiname: redirection.config
Zeilennummer: 0
Beschreibung: Die Konfigurationsdatei kann aufgrund unzureichender Berechtigungen nicht gelesen werden.
." />
" and exit code: 5
Do you have some idea how i can fix it?
Greetings,
Lasse
Do you have some idea how i can fix it?
Greetings,
Lasse
Tagged:
Answers
Thanks for your post and sorry to hear you're running into an issue!
Can I just confirm, does the profiler itself throw the System.BadImageFormatException or is it your application that throws the error when ANTS launches it? Does it still happen if you use Sampling mode of profiling?
I think the error in the log is likely a red herring, but as it says "The configuration file can not be read due to insufficient permissions" can you kindly try running the profiler explicitly as administrator to see if the error remains?
If so, can you please send us a screenshot of the error, and also check Event Viewer>Windows log>Application for any related entries?
Jessica Ramos | Product Support Engineer | Redgate Software
Have you visited our Help Center?
Had to do a restore and go back to the previously installed version (10.1.5.xxx)
I was launching a .Net Core project, and the bad image error was dumped in the Output in the profiler with a stacktrace back to my startup code.
After going back to the previous version, it all works again.
Googling only led me to switching to 32bit mode, but that option is only available for iis express profiling
Thanks @frostfire!
That note about 32-bitness led me to change the config of my test application to 32-bit, and I do then get the System.BadImageFormatException when profiling. However, even when I run the 32-bit application outside of the profiler, it still crashes (without a clear error), so I'm not sure if it's the same thing.
I was thinking that maybe even if my un-profiled application version crashes, that I could see if the previous version of the profiler was correctly launches the 32-bit version of dotnet.exe, while the latest launches the 64-bit, and that it would explain the problem.
However, I also get the System.BadImageFormatException error even when profiling with 10.1.5, and they're both launching the 64-bit version of dotnet.exe, so I'm not sure if what I'm experiencing is exactly the same.
Can I just confirm if your application does run as 32-bit? Can I also check--@frostfire, when you profile with the older version, can you check Task Manager to see the path of the dotnet.exe process that was launched? Is it C:\Program Files(x86)\dotnet\dotnet.exe or C:\Program Files\dotnet\dotnet.exe?
Thank you!
Jessica Ramos
Jessica Ramos | Product Support Engineer | Redgate Software
Have you visited our Help Center?
An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B) Type = System.BadImageFormatException Source = CoBRACommon at _ANTS_Managed_Begin_Async() at CoBRACommon.Utilities.CacheExtensions.GetAsync[T](ICacheManager cacheManager, String key, Func`1 acquire) at CoBRAMVC4Portal.Services.ProjectService.<GetProjectCacheAsync>d__26.MoveNext() in C:\Code\CoBRAGit\CoBRAMVC4Portal\Services\ProjectService.cs:line 352 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult() at CoBRAMVC4Portal.Areas.Tools.Controllers.API.RolesManagerAPIController.<CheckForPosition>d__11.MoveNext() in C:\Code\CoBRAGit\CoBRAMVC4Portal\Areas\Tools\Controllers\API\RolesManagerAPIController.cs:line 134
I can't move past this and ANTS is basically unusable for me while this is happening. I have the latest version of ANTS profiler on my box (10.1)
So sorry to hear you're running into an issue as well!
Based on the stack trace, I think your issue can likely be worked around by disabling Tools>Advanced Options>Profile with async awareness. (I wonder if this may have an effect for @frostfire as well.)
As to why async profiling is causing this though, I'm not yet sure - if you have a supported license, can you please open a ticket with support@red-gate.com so that we can investigate further?
Thank you!
Jessica Ramos | Product Support Engineer | Redgate Software
Have you visited our Help Center?
I can confirm that disabling async awareness as suggested above made the error go away.
I can confirm that disabling async awareness as suggested above made the error go away.
I can confirm that disabling async awareness as suggested above made the error go away.
I can confirm that disabling async awareness as suggested above made the error go away.
I can confirm that disabling async awareness as suggested above made the error go away.