-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
System.BadImageFormatException: 'Bad IL format.' #1622
Comments
I uninstall original .net core sdk and runtime; and reinstall VS2017 and 2.1 sdk. |
So sad, it doesn't work too. |
Make sure you have installed the latest VS and try to reinstall .net core. |
I debug into Microsoft.AspNetCore.Hosting and find out the error line: It will throw the exception: 'Bad IL format.' But if I rename this method to BuildCommonServices111 or other, It works. |
make sure you have installed version 2.1.300 and try to uninstall all previous versions. Also doublecheck you have finished all steps in the instruction I've sent you |
I have reinstall my OS, it works. |
Did you have NewRelic monitoring your .net app by any chance when you ran into the issue? |
@mangod3 I was about to comment here. My issue seemed to be Newrelic. Was returning the IL issue. I was building it and running it on docker. |
@Merurino Thanks for responding. After debugging the issue it looks like the 2.1 changes related to code versioning (https://github.com/dotnet/coreclr/blob/master/Documentation/design-docs/code-versioning-profiler-breaking-changes.md) are causing issues with profiling APIs. @noahfalk who should we follow up with to get this investigated, looks like the ILHeader is not getting initialized correctly after updating a method IL using SetILFunctionBody |
Sorry you are running into trouble! Feel free to start with me as the investigator and I can pull in others as needed. To help get us started:
|
Thanks for your response @noahfalk. Will package up a repro and send over email. |
I have a web job built on netcoreapp2.1 console application, targeting the win10-x64 and getting the "Unhandled Exception: System.BadImageFormatException: Could not load file or assembly exception". |
@joseclament - Are you aware of any .NET profiler or monitoring agent being used in your deployment environment? If not we should probably a open a new issue because there would be a decent chance that the root cause for you will be unrelated to the root cause here. |
@noahfalk , I am using AppInsight to push the logs, other than no profiling or tooling. |
@noahfalk I am seeing a similar issue using the AppDynamics .NET Core profiler agent on a netcoreapp2.1 application and .NET Core SDK 2.1.300. When the application starts, the following exception is thrown:
|
@noahfalk and @nil4 , I got the bottom of the problem. It took couple of days to get the bottom of the issue and made me bit nut. I was able to dig and find this link: https://tutel.me/c/programming/questions/42726350/how+to+change+azure+app+service+to+64bit Your core should be built on x86 version even if the deploying server(Azure) is based on 64 bit architecture. Because the 64 bit .NET core processes using the .NET core runtime (as opposed to the .NET Framework runtime) are not yet supported on Azure but is planned to be coming in the future. You can verify this by go to the kudu and type dotnet --info. You can see something like this below: .NET Core SDK (reflecting any global.json): Runtime Environment: Host (useful for support): .NET Core SDKs installed: You may be able to debug this locally "Any CPU" option as you might have x86 and x64 based libraries installed on your machine. I could not find any documentation on MSDN about this. I was assumed it would have been automatically support x64 version. Also make sure that the application setting is enabled for the "32" bit. |
I am not using Azure. The error occurs on my local PC when launching the application, with IIS Express, under the VS debugger, regardless of whether IIS Express 64-bit or 32-bit is selected. The application starts up correctly if I remove the AppDynamics.Agent.Windows NuGet package, or set |
is it possible for you to capture a full native stack of the exception? That might help with identifying if you are hitting the same issue or something different. |
@noahfalk Here are the steps to reproduce the issue I see. In a command prompt, run: mkdir Repro1622 && pushd Repro1622
dotnet new web
dotnet add package AppDynamics.Agent.Windows --version 4.4.3 Open the project in Visual Studio, and build it once. A number of files brought by the AppDynamics package show up under the project, including {
"controller": {
"host": "localhost",
"port": 443,
"account": "customer1",
"password": "c025be84-d72d-4f6e-b5b4-b33ce264992b",
"ssl": true,
"enable_tls12": true
},
"application": {
"name": "irrelevant",
"tier": "irrelevant",
"node": "irrelevant"
}
} These values are not important, they just need to be different than the default placeholders for the profiler to activate. Add a <configuration>
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%">
<environmentVariables>
<environmentVariable name="CORECLR_ENABLE_PROFILING" value="1" />
<environmentVariable name="CORECLR_PROFILER" value="{39AEABC1-56A5-405F-B8E7-C3668490DB4A}" />
<environmentVariable name="CORECLR_PROFILER_PATH_32" value="D:\Repro1622\bin\Debug\netcoreapp2.1\AppDynamics.Profiler_x86.dll"/>
<environmentVariable name="CORECLR_PROFILER_PATH_64" value="D:\Repro1622\bin\Debug\netcoreapp2.1\AppDynamics.Profiler_x64.dll"/>
</environmentVariables>
</aspNetCore>
</system.webServer>
</configuration>
Start debugging (F5) with IIS Express and note Find the newest
|
@joseclament - Glad you were able to get the bottom of it and very appreciated that you came back to post your findings in case others hit the same issue in the future! Indeed it looks like your issue had a similar symptom but different root cause than the other ones here. I created #1670 to track any further work there. @nil4 - Thanks for the repro! Let me try repro your issue so we can figure out if this is the same root cause or something else. |
@nil4 - Thanks, I was able to reproduce the problem easily using your excellent instructions! Although the AppDynamics issue is slighly different than the NewRelic one (AppDynamics does not call ICorProfilerInfo::SetILFunctionBody or ICorProfilerFunctionControl::SetILFunctionBody) , the fix I submitted earlier today (#18322) does solve both issues at the same time. I wasn't sure if you were an employee with AppDynamics or a customer of AppDynamics? For potential short term resolutions to the issue you could either continue to use .Net Core 2.0 or use a daily build of .Net Core that has this fix as soon as the installers are ready for download (I'll write back again when they are). A little further in the future I'm attempting to get this fix into the official servicing releases for 2.1. I can also try to reach out to AppDynamics to see if there are any additional solutions available for the issue. Let me know if you've got any other questions or concerns? |
@noahfalk glad I could help, and thank you for the update, much appreciated! I am a customer, and have opened an AppDynamics support ticket about this; will update it shortly with a link to this issue. |
Issue moved to dotnet/coreclr #18448 via ZenHub |
My build just stuck beacuse of a "Bad IL format" . I just clean up all the nuget caches (local & global) and restore everything. Hop this help. |
I've upgraded dotnetcore2.0 to 2.1, and upgraded all packages too.
When I startup my web application, the exception prompts.
StackTrace:
at Microsoft.AspNetCore.Hosting.WebHostBuilder.BuildCommonServices(AggregateException& hostingStartupErrors)
at Microsoft.AspNetCore.Hosting.WebHostBuilder.Build()
at GrapeLEAF.AdminService.Program.BuildWebHost(String[] args) in E:\workspace\dotnet\XXX\XXX.AdminService\XXX.AdminService\Program.cs:line 16
at GrapeLEAF.AdminService.Program.Main(String[] args) in E:\workspace\dotnet\XXX\XXX.AdminService\XXX.AdminService\Program.cs:line 12
The text was updated successfully, but these errors were encountered: