{"action":"created","issue":{"url":"https://api.github.com/repos/dotnet/coreclr/issues/18448","repository_url":"https://api.github.com/repos/dotnet/coreclr","labels_url":"https://api.github.com/repos/dotnet/coreclr/issues/18448/labels{/name}","comments_url":"https://api.github.com/repos/dotnet/coreclr/issues/18448/comments","events_url":"https://api.github.com/repos/dotnet/coreclr/issues/18448/events","html_url":"https://github.com/dotnet/coreclr/issues/18448","id":331827240,"node_id":"MDU6SXNzdWUzMzE4MjcyNDA=","number":18448,"title":"System.BadImageFormatException: 'Bad IL format.'","user":{"login":"Petermarcu","id":8228359,"node_id":"MDQ6VXNlcjgyMjgzNTk=","avatar_url":"https://avatars3.githubusercontent.com/u/8228359?v=4","gravatar_id":"","url":"https://api.github.com/users/Petermarcu","html_url":"https://github.com/Petermarcu","followers_url":"https://api.github.com/users/Petermarcu/followers","following_url":"https://api.github.com/users/Petermarcu/following{/other_user}","gists_url":"https://api.github.com/users/Petermarcu/gists{/gist_id}","starred_url":"https://api.github.com/users/Petermarcu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Petermarcu/subscriptions","organizations_url":"https://api.github.com/users/Petermarcu/orgs","repos_url":"https://api.github.com/users/Petermarcu/repos","events_url":"https://api.github.com/users/Petermarcu/events{/privacy}","received_events_url":"https://api.github.com/users/Petermarcu/received_events","type":"User","site_admin":false},"labels":[{"id":972434830,"node_id":"MDU6TGFiZWw5NzI0MzQ4MzA=","url":"https://api.github.com/repos/dotnet/coreclr/labels/Servicing-Approved-2.1.3","name":"Servicing-Approved-2.1.3","color":"0e8a16","default":false},{"id":963839699,"node_id":"MDU6TGFiZWw5NjM4Mzk2OTk=","url":"https://api.github.com/repos/dotnet/coreclr/labels/area-CodeVersioning","name":"area-CodeVersioning","color":"d4c5f9","default":false}],"state":"open","locked":false,"assignee":{"login":"noahfalk","id":6243776,"node_id":"MDQ6VXNlcjYyNDM3NzY=","avatar_url":"https://avatars0.githubusercontent.com/u/6243776?v=4","gravatar_id":"","url":"https://api.github.com/users/noahfalk","html_url":"https://github.com/noahfalk","followers_url":"https://api.github.com/users/noahfalk/followers","following_url":"https://api.github.com/users/noahfalk/following{/other_user}","gists_url":"https://api.github.com/users/noahfalk/gists{/gist_id}","starred_url":"https://api.github.com/users/noahfalk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/noahfalk/subscriptions","organizations_url":"https://api.github.com/users/noahfalk/orgs","repos_url":"https://api.github.com/users/noahfalk/repos","events_url":"https://api.github.com/users/noahfalk/events{/privacy}","received_events_url":"https://api.github.com/users/noahfalk/received_events","type":"User","site_admin":false},"assignees":[{"login":"noahfalk","id":6243776,"node_id":"MDQ6VXNlcjYyNDM3NzY=","avatar_url":"https://avatars0.githubusercontent.com/u/6243776?v=4","gravatar_id":"","url":"https://api.github.com/users/noahfalk","html_url":"https://github.com/noahfalk","followers_url":"https://api.github.com/users/noahfalk/followers","following_url":"https://api.github.com/users/noahfalk/following{/other_user}","gists_url":"https://api.github.com/users/noahfalk/gists{/gist_id}","starred_url":"https://api.github.com/users/noahfalk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/noahfalk/subscriptions","organizations_url":"https://api.github.com/users/noahfalk/orgs","repos_url":"https://api.github.com/users/noahfalk/repos","events_url":"https://api.github.com/users/noahfalk/events{/privacy}","received_events_url":"https://api.github.com/users/noahfalk/received_events","type":"User","site_admin":false}],"milestone":{"url":"https://api.github.com/repos/dotnet/coreclr/milestones/19","html_url":"https://github.com/dotnet/coreclr/milestone/19","labels_url":"https://api.github.com/repos/dotnet/coreclr/milestones/19/labels","id":3358831,"node_id":"MDk6TWlsZXN0b25lMzM1ODgzMQ==","number":19,"title":"2.1.x","description":".NET Core 2.1 Servicing Updates - https://github.com/dotnet/core/tree/master/release-notes (pending 2.1 final RTW release)","creator":{"login":"karelz","id":5776068,"node_id":"MDQ6VXNlcjU3NzYwNjg=","avatar_url":"https://avatars2.githubusercontent.com/u/5776068?v=4","gravatar_id":"","url":"https://api.github.com/users/karelz","html_url":"https://github.com/karelz","followers_url":"https://api.github.com/users/karelz/followers","following_url":"https://api.github.com/users/karelz/following{/other_user}","gists_url":"https://api.github.com/users/karelz/gists{/gist_id}","starred_url":"https://api.github.com/users/karelz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/karelz/subscriptions","organizations_url":"https://api.github.com/users/karelz/orgs","repos_url":"https://api.github.com/users/karelz/repos","events_url":"https://api.github.com/users/karelz/events{/privacy}","received_events_url":"https://api.github.com/users/karelz/received_events","type":"User","site_admin":false},"open_issues":1,"closed_issues":17,"state":"open","created_at":"2018-05-19T17:04:19Z","updated_at":"2018-08-06T20:29:06Z","due_on":null,"closed_at":null},"comments":25,"created_at":"2018-06-13T03:19:48Z","updated_at":"2018-08-16T18:05:08Z","closed_at":null,"author_association":"MEMBER","body":"@atpyk commented on [Wed May 30 2018](https://github.com/dotnet/core/issues/1622)\n\n\r\nI've upgraded dotnetcore2.0 to 2.1, and upgraded all packages too.\r\nWhen I startup my web application, the exception prompts.\r\n\r\nStackTrace:\r\n   at Microsoft.AspNetCore.Hosting.WebHostBuilder.BuildCommonServices(AggregateException& hostingStartupErrors)\r\n   at Microsoft.AspNetCore.Hosting.WebHostBuilder.Build()\r\n   at GrapeLEAF.AdminService.Program.BuildWebHost(String[] args) in E:\\workspace\\dotnet\\XXX\\XXX.AdminService\\XXX.AdminService\\Program.cs:line 16\r\n   at GrapeLEAF.AdminService.Program.Main(String[] args) in E:\\workspace\\dotnet\\XXX\\XXX.AdminService\\XXX.AdminService\\Program.cs:line 12\r\n\n\n---\n\n@atpyk commented on [Thu May 31 2018](https://github.com/dotnet/core/issues/1622#issuecomment-393436939)\n\nI uninstall original .net core sdk and runtime; and reinstall VS2017 and 2.1 sdk. \r\nI create a new webapi application by scaffold, it doesn't work.\r\n\n\n---\n\n@VladislavAntonyuk commented on [Thu May 31 2018](https://github.com/dotnet/core/issues/1622#issuecomment-393459163)\n\nhttps://blogs.msdn.microsoft.com/webdev/2018/05/07/asp-net-core-2-1-0-rc1-now-available/\n\n---\n\n@atpyk commented on [Thu May 31 2018](https://github.com/dotnet/core/issues/1622#issuecomment-393465743)\n\nSo sad, it doesn't work too.\n\n---\n\n@VladislavAntonyuk commented on [Thu May 31 2018](https://github.com/dotnet/core/issues/1622#issuecomment-393482909)\n\nMake sure you have installed the latest VS and try to reinstall .net core.\r\nRoolback your changes to .net core 2.0 and follow the instruction I have sent you\n\n---\n\n@atpyk commented on [Thu May 31 2018](https://github.com/dotnet/core/issues/1622#issuecomment-393746933)\n\nI debug into Microsoft.AspNetCore.Hosting and find out the error line:\r\n var hostingServices = BuildCommonServices(out var hostingStartupErrors);\r\n\r\nIt will throw the exception: 'Bad IL format.'\r\n\r\nBut if I rename this method to BuildCommonServices111 or other, It works.\r\nSo weird~\r\nIt seems like the namespace \"Microsoft.AspNetCore.Hosting\"  conflicts with others, the .net runtime involves dlls of different version at same time.\n\n---\n\n@VladislavAntonyuk commented on [Fri Jun 01 2018](https://github.com/dotnet/core/issues/1622#issuecomment-393803561)\n\nmake 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 \n\n---\n\n@atpyk commented on [Fri Jun 01 2018](https://github.com/dotnet/core/issues/1622#issuecomment-393810220)\n\nI have reinstall my OS, it works.\r\nThanks.\n\n---\n\n@mangod3 commented on [Sat Jun 02 2018](https://github.com/dotnet/core/issues/1622#issuecomment-394127431)\n\nDid you have NewRelic monitoring your .net app by any chance when you ran into the issue?\n\n---\n\n@Merurino commented on [Sun Jun 03 2018](https://github.com/dotnet/core/issues/1622#issuecomment-394201129)\n\n@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.\r\n\r\n\n\n---\n\n@mangod3 commented on [Sun Jun 03 2018](https://github.com/dotnet/core/issues/1622#issuecomment-394224256)\n\n@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\n\n---\n\n@noahfalk commented on [Mon Jun 04 2018](https://github.com/dotnet/core/issues/1622#issuecomment-394493650)\n\n 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:\r\n1) Could you post steps I can follow to try reproducing the problem?\r\n2) Can you let me know what you observed while debugging that lead you to your conclusions?\n\n---\n\n@mangod3 commented on [Mon Jun 04 2018](https://github.com/dotnet/core/issues/1622#issuecomment-394511301)\n\nThanks for your response @noahfalk. Will package up a repro and send over email. \n\n---\n\n@joseclament commented on [Wed Jun 06 2018](https://github.com/dotnet/core/issues/1622#issuecomment-395119603)\n\nI 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\". \r\nI haven't had any issue with locally. Deployed using the visual studio directly to the app service. Any thoughts?\n\n---\n\n@noahfalk commented on [Wed Jun 06 2018](https://github.com/dotnet/core/issues/1622#issuecomment-395221204)\n\n@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.\n\n---\n\n@joseclament commented on [Thu Jun 07 2018](https://github.com/dotnet/core/issues/1622#issuecomment-395337310)\n\n@noahfalk , I am using AppInsight to push the logs, other than no profiling or tooling.\r\nLet me know if I need to open a new issue.\r\n\n\n---\n\n@nil4 commented on [Thu Jun 07 2018](https://github.com/dotnet/core/issues/1622#issuecomment-395442460)\n\n@noahfalk I am seeing a similar issue using the [AppDynamics .NET Core profiler agent](https://docs.appdynamics.com/display/PRO44/Install+the+.NET+Core+Microservices+Agent+for+Windows) on a netcoreapp2.1 application and .NET Core SDK 2.1.300. \r\n\r\nWhen the application starts, the following exception is thrown:\r\n\r\n```\r\nSystem.BadImageFormatException\r\n  HResult=0x8007000B\r\n  Message=Bad IL format.\r\n  Source=System.Private.CoreLib\r\n  StackTrace:\r\n   at System.AppDomainManager..ctor()\r\n   at System.Reflection.Assembly.GetEntryAssembly()\r\n   at Microsoft.AspNetCore.Hosting.WebHostBuilder.BuildCommonServices(AggregateException& hostingStartupErrors)\r\n   at Microsoft.AspNetCore.Hosting.WebHostBuilder.Build()\r\n   at MyApp.Web.Startup.Main(String[] args) \r\n```\r\n\n\n---\n\n@joseclament commented on [Thu Jun 07 2018](https://github.com/dotnet/core/issues/1622#issuecomment-395448692)\n\n@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\r\n\r\nYour 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:\r\n\r\n.NET Core SDK (reflecting any global.json):\r\n Version:   2.1.300\r\n Commit:    32f29b6eb9\r\n\r\nRuntime Environment:\r\n OS Name:     Windows\r\n OS Version:  10.0.14393\r\n OS Platform: Windows\r\n RID:         win10-x86\r\n _Base Path:   D:\\Program Files (x86)\\dotnet\\sdk\\2.1.300\\_ [**You  can see only the x86 version here**]\r\n\r\nHost (useful for support):\r\n  Version: 2.1.0\r\n  Commit:  caa7b7e2ba\r\n\r\n.NET Core SDKs installed:\r\n  1.1.8 [D:\\Program Files (x86)\\dotnet\\sdk]\r\n  2.1.101 [D:\\Program Files (x86)\\dotnet\\sdk]\r\n  2.1.300 [D:\\Program Files (x86)\\dotnet\\sdk]\r\n\r\nYou 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.\r\n\r\n\n\n---\n\n@nil4 commented on [Thu Jun 07 2018](https://github.com/dotnet/core/issues/1622#issuecomment-395465136)\n\nI 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.\r\n\r\nThe application starts up correctly if I remove the AppDynamics.Agent.Windows NuGet package, or set `CORECLR_ENABLE_PROFILING` environment variable to `0` in my Web.config (disabling the profiler).\n\n---\n\n@mangod3 commented on [Thu Jun 07 2018](https://github.com/dotnet/core/issues/1622#issuecomment-395478892)\n\nis 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. \n\n---\n\n@nil4 commented on [Thu Jun 07 2018](https://github.com/dotnet/core/issues/1622#issuecomment-395487431)\n\n@noahfalk  Here are the steps to reproduce the issue I see. In a command prompt, run:\r\n\r\n```cmd\r\nmkdir Repro1622 && pushd Repro1622\r\ndotnet new web\r\ndotnet add package AppDynamics.Agent.Windows --version 4.4.3\r\n```\r\nOpen the project in Visual Studio, and build it once. \r\n\r\nA number of files brought by the AppDynamics package show up under the project, including `Repro1622.AppDynamicsConfig.json`. Edit this file and replace its content with:\r\n\r\n```json\r\n{\r\n  \"controller\": {\r\n    \"host\": \"localhost\",\r\n    \"port\": 443,\r\n    \"account\": \"customer1\",\r\n    \"password\": \"c025be84-d72d-4f6e-b5b4-b33ce264992b\",\r\n    \"ssl\": true,\r\n    \"enable_tls12\": true\r\n  },\r\n  \"application\": {\r\n    \"name\": \"irrelevant\",\r\n    \"tier\": \"irrelevant\",\r\n    \"node\": \"irrelevant\"\r\n  }\r\n}\r\n```\r\n\r\nThese values are not important, they just need to be different than the default placeholders for the profiler to activate.\r\n\r\nAdd a `Web.config` file to the project, with the following content:\r\n\r\n```xml\r\n<configuration>\r\n  <system.webServer>\r\n    <handlers>\r\n      <add name=\"aspNetCore\" path=\"*\" verb=\"*\" modules=\"AspNetCoreModule\" resourceType=\"Unspecified\" />\r\n    </handlers>\r\n    <aspNetCore processPath=\"%LAUNCHER_PATH%\" arguments=\"%LAUNCHER_ARGS%\">\r\n      <environmentVariables>\r\n        <environmentVariable name=\"CORECLR_ENABLE_PROFILING\" value=\"1\" />\r\n        <environmentVariable name=\"CORECLR_PROFILER\" value=\"{39AEABC1-56A5-405F-B8E7-C3668490DB4A}\" />\r\n\r\n        <environmentVariable name=\"CORECLR_PROFILER_PATH_32\" value=\"D:\\Repro1622\\bin\\Debug\\netcoreapp2.1\\AppDynamics.Profiler_x86.dll\"/>\r\n        <environmentVariable name=\"CORECLR_PROFILER_PATH_64\" value=\"D:\\Repro1622\\bin\\Debug\\netcoreapp2.1\\AppDynamics.Profiler_x64.dll\"/>\r\n      </environmentVariables>\r\n    </aspNetCore>\r\n  </system.webServer>\r\n</configuration>\r\n```\r\n\r\n⚠️ Per the [AppDynamics docs](https://docs.appdynamics.com/display/PRO44/Install+the+.NET+Core+Microservices+Agent+for+Windows), the two `CORECLR_PROFILER_PATH_*` variables must be full paths; **adjust as required**.\r\n\r\nStart debugging (F5) with IIS Express and note `BadImageFormatException` is thrown at `System.AppDomainManager..ctor()` when the application starts.\r\n\r\nFind the newest `.log` file under *%ProgramData%\\AppDynamics\\DotNetAgent\\Logs\\Profiler*, which should be similar to:\r\n```\r\n2018-06-07 18:22:31.086553<info>:Use CoreCLR profiler\r\n2018-06-07 18:22:31.089553<info>:Should instrument standalone profiler process (config found at D:\\Repro1622\\bin\\Debug\\netcoreapp2.1\\Repro1622.AppDynamicsConfig.json): dotnet as app Repro1622.dll\r\n2018-06-07 18:22:31.092555<info>:Agent Configuration: {\"controller\":{\"account\":\"customer1\",\"enableTls12\":true,\"ssl\":true,\"host\":\"localhost\",\"password\":\"***\",\"port\":443},\"application\":{\"tier\":\"irrelevant\",\"node\":\"irrelevant\",\"name\":\"irrelevant\"}}\r\n2018-06-07 18:22:31.092555<info>:Enabled rejit normally, disabled all NGEN images.\r\n2018-06-07 18:22:31.163553<error>:InjectMEE failed.\r\n2018-06-07 18:22:31.935346<info>:Transforming 57540:clrhost:System.Void System.AppDomainManager..ctor() with [[],[]]\r\n```\n\n---\n\n@noahfalk commented on [Thu Jun 07 2018](https://github.com/dotnet/core/issues/1622#issuecomment-395550918)\n\n@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.\r\n\r\n@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. \n\n---\n\n@noahfalk commented on [Thu Jun 07 2018](https://github.com/dotnet/core/issues/1622#issuecomment-395614005)\n\n@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.\r\n\r\nI 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.\r\n\r\nLet me know if you've got any other questions or concerns?\n\n---\n\n@nil4 commented on [Fri Jun 08 2018](https://github.com/dotnet/core/issues/1622#issuecomment-395689332)\n\n@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.\n\n"},"comment":{"url":"https://api.github.com/repos/dotnet/coreclr/issues/comments/413634404","html_url":"https://github.com/dotnet/coreclr/issues/18448#issuecomment-413634404","issue_url":"https://api.github.com/repos/dotnet/coreclr/issues/18448","id":413634404,"node_id":"MDEyOklzc3VlQ29tbWVudDQxMzYzNDQwNA==","user":{"login":"rv-calbert","id":38321952,"node_id":"MDQ6VXNlcjM4MzIxOTUy","avatar_url":"https://avatars2.githubusercontent.com/u/38321952?v=4","gravatar_id":"","url":"https://api.github.com/users/rv-calbert","html_url":"https://github.com/rv-calbert","followers_url":"https://api.github.com/users/rv-calbert/followers","following_url":"https://api.github.com/users/rv-calbert/following{/other_user}","gists_url":"https://api.github.com/users/rv-calbert/gists{/gist_id}","starred_url":"https://api.github.com/users/rv-calbert/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rv-calbert/subscriptions","organizations_url":"https://api.github.com/users/rv-calbert/orgs","repos_url":"https://api.github.com/users/rv-calbert/repos","events_url":"https://api.github.com/users/rv-calbert/events{/privacy}","received_events_url":"https://api.github.com/users/rv-calbert/received_events","type":"User","site_admin":false},"created_at":"2018-08-16T18:05:08Z","updated_at":"2018-08-16T18:05:08Z","author_association":"NONE","body":"Looks like the August release of the SDK is out (v2.1.4) but it looks like includes coreclr v 2.1.2 still. Does this mean we will have to wait for the September release? Or is there another release coming?"}}
{"actor":{"display_login":"rv-calbert"}}