BadImageFormatException with Microsoft.mshtml

G

Guest

Hello,

I have written an application in .NET (C#) which uses some stuff from the
Microsoft.mshtml. Unfortunately some customers reported that they are
missing this DLL. Therefore we now redistribute a copy of the
Microsoft.mshtml-DLL with our installation routine (just copy it into the
application directory). Now the application works on most machines, but on a
couple of machines I get a "BadImageFormatException" (details below).

What could be the reason for this exception? How can I fix it and ensure
that my application can load the DLL? Could it be a version conflict or
policy problem?

Thanks in advance!
Erich

------

System.BadImageFormatException: The format of the file 'Microsoft.mshtml' is
invalid. File name: "Microsoft.mshtml" at [...]

=== Pre-bind state information ===
LOG: DisplayName = Microsoft.mshtml, Version=7.0.3300.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a (Fully-specified)
LOG: Appbase = C:\MyApp\
LOG: Initial PrivatePath = NULL
Callong assembly: MyApp, Version=1.0.1942.28310, Culture=neutral,
PublicKeyToken=null.
===

LOG: Publisher policy file is not found.
LOG: Host configuration file not found.
LOG: Using machine configuration file from
C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\config\machine.config.
LOG: Post-policy reference: Microsoft.mshtml, Version=7.0.3300.0,
Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
LOG: Attempting download of new URL file:///C:/MyApp/Microsoft.mshtml.DLL.
 
K

Kevin Yu [MSFT]

Hi Erich,

First of all, I would like to confirm my understanding of your issue. From
your description, I understand that when you have copy the Microsoft.mshtml
with you app. However, a BadImageFormatException was thrown sometimes. If
there is any misunderstanding, please feel free to let me know.

As far as I know, the MSHTML.DLL file is distributed with many products.
For example, .NET framework 1.1, Internet Explorer 6.0 and so on. So I
assume that the the problem might occur because of the Primary Interop
Assembly Microsoft.mshtml is not installed properly.

Since copying the Microsoft.mshtml with your app doesn't work, I suggest
you try to install the PIA into the GAC using gacutil.exe. By default, the
app will look into GAC for strong named assembly first.

If that still fails, you can try to use the Assembly Binding Log Viewer to
check for the binding failures. Here is the usage of Assembly Binding Log
Viewer.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cptools/htm
l/cpgrffusionlogviewerfuslogvwexe.asp

HTH.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top