BadImageFormatException when updating a Dynamics CRM Plug-in

3 comments

Today I was working on a Dynamics CRM 4.0 Plug-in we’ve developed in the past and I needed to update the plug-in on our CRM server.

When I loaded the assembly in the Plug-in Registration tool I got the following exception:

Unhandled Exception: System.BadImageFormatException: Could not load file or assembly 'Microsoft.Crm.Sdk, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies.
An attempt was made to load a program with an incorrect format.
   at System.Reflection.Assembly._GetExportedTypes()
   at PluginRegistrationTool.AssemblyReader.RetrievePluginsFromAssembly(String path)
   at PluginRegistrationTool.AssemblyReader.RetrievePluginsFromAssembly(String path)
   at PluginRegistrationTool.RegistrationHelper.RetrievePluginsFromAssembly(String pathToAssembly)
   at PluginRegistrationTool.PluginRegistrationForm.btnLoadAssembly_Click(Object sender, EventArgs e)

Appearently this was due to the fact I was working on a 64 bit environment. When you place the tool in the 64bit folder of the sdk\bin folder, the error doesn’t occur anymore and you’ll be able to succesfully update your plug-in.

No related posts.

Tagged . Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

3 Comments

  1. Vivek Garud
    Posted January 20, 2010 at 7:55 pm | Permalink

    I have this exact same issue. I am developing on a 64bit box. But I dont see any folder named "64bit" in sdk\bin. Do I create one?
    And did you mean move the PluginRegistration.exe into sdk\bin\64bit directory?
    Thanks!

  2. Peter
    Posted January 20, 2010 at 7:55 pm | Permalink

    Yes, you need to place the pluginregistration.exe into the 64bit folder. I don’t know why you don’t have a 64 bit folder in there. You can create one, but you will need the 64bit assemblies in there as well. So I guess you need to download the latest version of the sdk.

  3. Olivier
    Posted February 2, 2010 at 9:31 am | Permalink

    thanks a lot! i try some solution but none work. I copy the exe into the sdk/bin/x64 directory and i can update my plugins.

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>