Bad IL Format Assembly.LoadFrom Web App exe asp.net core RRS feed

  • Question

  • Hi,

    I am trying to find the types (classes) that are part of the ViewModels for an Asp.net Core 3.1 web app executable.

    I am using an asp.net core 3.1 console app as part of the post build process. (The idea being that I would like to auto generate some typescript files based on the classes marked by custom attributes))

    I can load other dlls in the target directory using Assembly.LoadFrom(filepath). But when I try to load the exe using this technique it fails due to "Bad IL Format". I have created the simplest solution with a simple web app and a simple console app each using the same target and the same cpu configuration. I have even added the <loadFromRemoteSources enabled="true|false"/> to the app.config.

    Nothing I have tried has stopped this error from being raised.

    Any thoughts or direction would be appreciated.



    • Moved by CoolDadTx Friday, January 3, 2020 3:55 PM ASP.NET related
    Thursday, January 2, 2020 8:16 PM

All replies

  • First off, there is no such thing as an ASP.NET Console program. It's simple desktop program,  and the Core console project can be created by VS2017, VS2019 and at the .NET Core command line, a simple console project.  

    The "Bad IL Format" usually indicates that you are may be trying to use a 32bit assembly in a 64bit assembly solution or vice versa  -- x86 vs 64.

    Thursday, January 2, 2020 8:54 PM
  • I think he is referring to "Self-host ASP.NET Core App". (Something like this, analogical to running SpringBoot App with java.exe directly without a web server such as Tomcat)

    The "Bad IL Format" thing may also raise if the EXE in question is not a .NET binary.

    • Edited by cheong00 Friday, January 3, 2020 1:22 AM
    Friday, January 3, 2020 1:21 AM
  • Hi Mike,

    Thank you for posting here.

    Starting with ASP.Net Core 3.0, when you run ASP.Net Core web programs, an exe file will be created.

    Personally, it's a bit like Tomcat.

    However, the .exe file generated in a .NET Core 3.0 application is not an IL assembly, but a native host executable that fin

    By loading the .dll file next to the .exe file with the same project name, you should be able to load the plugin.

    Hope this could be helpful.

    Best Regards,


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, January 3, 2020 3:08 AM
  • This forum is for C#-specific questions only. Please post questions related to ASP.NET Core in the ASP.NET forums.

    Michael Taylor http://www.michaeltaylorp3.net

    Friday, January 3, 2020 3:55 PM