Fixing Tridion Content Delivery Deployment Errors: “Unable to load DLL ‘xmogrt'” and “System.BadImageFormatException”

I’ve recently helped a colleague with an issue when trying to deploy our Tridion DD4T .NET project to a Dev machine.   The issue was a “System.BadImageFormatException” related to the Tridion’s Java wrapper Juggernet.  

However, at first we were getting the error: “Unable to load DLL ‘xmogrt': The specified module could not be found. (Exception from HRESULT: 0x8007007E)”.  It was weird because on my VM, with the exact same files in the bin, it ran fine.  Turns out, it worked on my VM because my %TRIDION_HOME% was set with the file in it.  

We followed the answers in this post (which you’ve probably read already before coming to this article: http://stackoverflow.com/questions/13918310/unable-to-load-dll-xmogrt-from-tridion-metadata-query) and placed the xmogrt.dll and its dependencies in the bin.  However, we now ended with the “System.BadImageFormatException”:

An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)

Server Error in '/' Application.

An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.BadImageFormatException: An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)

Here is how we solved the problem: 

  1. Uninstall all Java (you may have several versions of the JVM installed.  Uninstall all of them)
  2. Install the latest Java 6 JRE (though we installed the JDK 1.6_45).
  3. Check that it’s successfully installed by typing java –version from the command line.
  4. Verify that ‘xmogrt.dll’ is in the bin folder of your app and is not corrupt.  In our case the ‘xmogrt.dll’ file was only 840kb for some reason.  It should be 1630 KB.
  5. Do an iisreset.

Here is the long answer

xmogrt.dll is an unmanaged C++ assembly that is largely the Juggernet Java wrapper used by Tridion (if you’ve wondered about those jar files in the bin/lib).  This compilation version of this DLL must match the CPU instructionset, i.e. x86 or x86-64).  It must also match the latest Tridion-supported Java version, i.e. 1.6_xx x86 or 1.6_xx 64-bit (of java 1.7 for Tridion 2013).  If there is a mismatch in either, then you’ll receive the “System.BadImageFormatException” error.Look at the Juggernet documentation for more details about how Juggernet works and this error here: http://codemesh.com/products/vfour/tutorial/dotnet/v3/L_02_run_app.html, scroll down to the section “Common Runtime Issues You Might Encounter”.  Also, the Juggernet architecture diagram (found here: http://codemesh.com/products/vfour/dotnetruntimes.html) provides a nice deal of insight into understanding how the Tridion CD API is converted to .NET.

 

2 thoughts on “Fixing Tridion Content Delivery Deployment Errors: “Unable to load DLL ‘xmogrt'” and “System.BadImageFormatException”

  1. “Verify that ‘xmogrt.dll’ is in the bin folder of your app and is not corrupt. In our case the ‘xmogrt.dll’ file was only 840kb for some reason. It should be 1630 KB” – This is not corrupt – its the 32bit version of the DLL (hence half the size I guess!).

    You will see the BadImageFormatException when you have a mix of 32 and 64 bit DLLs running. I had this recently because I was running the 32 bit DLLs in a web application within Visual Studio (which doesn’t support 64bit) but one of the projects build settings had been set from build for AnyCPU to specifically 64bit…

  2. Pingback: Tridion DD4T Survival Tips | Tridion Consulting, Programming and Training Services

Leave a Reply

Your email address will not be published. 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=""> <s> <strike> <strong>