Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Dynamics 365 Plugin Error: System.BadImageFormatException: Bad IL range

(0) ShareShare
ReportReport
Posted on by

Good afternoon can somebody help me with the following issue, I'm facing a very strange problem in production Enviroment that does not happen in QA or Development enviroments:

CRM Internal Error in Application.Unexpected exception from plug-in (Execute): AssamblyName.PluginName: System.BadImageFormatException: Bad IL range.

I have already researched about possible causes: 

https://support.microsoft.com/en-us/help/967163/badimageformatexception-occurs-when-instantiating-types-defined-in-a-r

Cause
32-bit processes can only load and execute 32-bit modules in process. Likewise, 64-bit processes can only load and execute 64-bit modules in process.

If your application is compiled to target a specific platform (x86 or x64), but attempts to load and execute an assembly that targets a different platform, the BadImageFormatException will occur. This behavior will also occur if your application is compiled targeting the "AnyCPU" platform, and then is run an operating system whose platform differs than the assembly whose type you are trying to instantiate. For example, if the main application is compiled to "AnyCPU", and references an assembly that targets x86, then if you run the application on an x64 operating system, the BadImageFormatException will occur.

This behavior is by design.

But my  plugin is already compiled ass AnyCPU and in .Net Framework 4.5.2 

Microsoft Dynamics 365 Version 1612 (8.2.2.160)

Thanks in regards.

*This post is locked for comments

  • Community Member Profile Picture
    on at
    RE: Dynamics 365 Plugin Error: System.BadImageFormatException: Bad IL range

    I'm sorry, the plugin profiler it's not installed in Production I got confused between enviroments when I check.

    Thank you

  • ashlega Profile Picture
    34,477 on at
    RE: Dynamics 365 Plugin Error: System.BadImageFormatException: Bad IL range

    I realize it's probably not a 100% justified suggestion, but I would uninstall the profiler, update the assembly, and see whether that changes anything.

  • Community Member Profile Picture
    on at
    RE: Dynamics 365 Plugin Error: System.BadImageFormatException: Bad IL range

    I do have install the plugin profiler in the Production enviroment, but I'm not profilling any plugin.

    Thank you for your response.

  • ashlega Profile Picture
    34,477 on at
    RE: Dynamics 365 Plugin Error: System.BadImageFormatException: Bad IL range

    That's unusual, especially if it's the same version in the QA..

    You are not profiling that plugin in production(using plugin profiler), aren't you?

  • Community Member Profile Picture
    on at
    RE: Dynamics 365 Plugin Error: System.BadImageFormatException: Bad IL range

    Hello, thank you for your response, No I'm not merging the assambly with any other DLL

  • ashlega Profile Picture
    34,477 on at
    RE: Dynamics 365 Plugin Error: System.BadImageFormatException: Bad IL range

    Hi,

     are you using ILMerge to add other dll-s to your plugin?

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,865 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,723 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156 Moderator

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans