web
You’re offline. This is a read only version of the page.
close
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

I have the same question (0)
  • ashlega Profile Picture
    34,477 on at

    Hi,

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

  • Community Member Profile Picture
    on at

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

  • ashlega Profile Picture
    34,477 on at

    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

    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

    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

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

    Thank you

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans