BadImageFormatException

P

Phil Jollans

Hi

I have received an error message from a user of my software, which is an
Add-In for Visual Studio 2005. The user is using a French version of Visual
Studio.

A BadImageFormatException occurs, and it appears that the FileName property
in the BadImageFormatException structure is an empty string.

The stack trace is as follows:

à System.ModuleHandle._GetPEKind(Int32& peKind, Int32& machine)
à System.ModuleHandle.GetPEKind(PortableExecutableKinds& peKind,
ImageFileMachine& machine)
à System.Reflection.Module.GetPEKind(PortableExecutableKinds& peKind,
ImageFileMachine& machine)
à System.Reflection.Assembly.ComputeProcArchIndex()
à System.Reflection.Assembly.GetName(Boolean copiedName)
à System.Reflection.Assembly.GetName()
à
System.ComponentModel.Design.RuntimeLicenseContext.CaseInsensitiveManifestResourceStreamLookup(Assembly
satellite, String name)
à
System.ComponentModel.Design.RuntimeLicenseContext.GetSavedLicenseKey(Type
type, Assembly resourceAssembly)
à
System.ComponentModel.LicenseManager.LicenseInteropHelper.GetCurrentContextInfo(Int32&
fDesignTime, IntPtr& bstrKey, RuntimeTypeHandle rth)
à MultiLang.modGlobalDbUtil.OpenGlobalDatabaseConnection()
à MultiLang.ctlToolWindow.InitAddInWindow(DTE newVal)
à MultiLang.Connect.OnConnection(Object application, ext_ConnectMode
connectMode, Object addInInst, Array& custom)

The last function in my software is
MultiLang.modGlobalDbUtil.OpenGlobalDatabaseConnection
which opens an ADO database connection to an mdb (access 2000) database
file.

This is ADO and not ADO.NET.

I have simply no idea why execution is entering LicenseManager code. I have
tried putting a breakpoint in this module (via the disassembly window) but
as far as I can tell it is not entered on my system.

I am totally baffled by this error and would appreciate any help.

Thanks in advance,
Phil
 
P

Phil Jollans

What I wrote before was not quite correct. I have now succeeded in setting
breakpoints in the lower level functions and have got the slightly more
detailed stack trace, listed below.


mscorlib.dll!System.ModuleHandle.GetPEKind(out
System.Reflection.PortableExecutableKinds peKind =
NotAPortableExecutableImage, out System.Reflection.ImageFileMachine
machine = 0)
mscorlib.dll!System.Reflection.Module.GetPEKind(out
System.Reflection.PortableExecutableKinds peKind, out
System.Reflection.ImageFileMachine machine) + 0x22 bytes
mscorlib.dll!System.Reflection.Assembly.ComputeProcArchIndex() + 0x43
bytes
mscorlib.dll!System.Reflection.Assembly.GetName(bool copiedName) + 0xd3
bytes
mscorlib.dll!System.Reflection.Assembly.GetName() + 0x7 bytes
System.dll!System.ComponentModel.Design.RuntimeLicenseContext.CaseInsensitiveManifestResourceStreamLookup(System.Reflection.Assembly
satellite = {System.Reflection.Assembly}, string name =
"mscorlib.dll.licenses") + 0x2e bytes
System.dll!System.ComponentModel.Design.RuntimeLicenseContext.GetSavedLicenseKey(System.Type
type = {Name = Cannot evaluate expression because the code of the current
method is optimized. FullName = Cannot evaluate expression because the code
of the current method is optimized.}, System.Reflection.Assembly
resourceAssembly) + 0x21b bytes
System.dll!System.ComponentModel.LicenseManager.LicenseInteropHelper.GetCurrentContextInfo(ref
int fDesignTime, ref System.IntPtr bstrKey = 0, System.RuntimeTypeHandle
rth) + 0x5c bytes
[Frames below may be incorrect and/or missing, no symbols loaded for
mscorwks.dll]
ole32.dll!77515343()
ole32.dll!77515e4b()
MultiLang.dll!MultiLang.modGlobalDbUtil.OpenGlobalDatabaseConnection()
Line 33 + 0xa bytes Basic
MultiLang.dll!MultiLang.ctlToolWindow.InitAddInWindow(EnvDTE.DTE newVal =
{System.__ComObject}) Line 968 + 0x5 bytes Basic
MultiLang.dll!MultiLang.Connect.OnConnection(Object application =
{System.__ComObject}, Extensibility.ext_ConnectMode connectMode =
Extensibility.ext_ConnectMode.ext_cm_AfterStartup, Object addInInst =
{System.__ComObject}, System.Array custom = {System.Array}) Line 325 + 0x13
bytes Basic


In addition, I can now see that this senario occurs on creating an ADO
connection object, specifically in the first of three call instructions
generated, although I don't know what these specific calls do.

gdb = New ADODB.Connection
00000145 mov ecx,5FB6DBCh
---> 0000014a call 740C9DA4
0000014f mov dword ptr [ebp-64h],eax
00000152 mov ecx,dword ptr [ebp-64h]
00000155 call 001F2FD8
0000015a mov eax,dword ptr [ebp-64h]
0000015d lea edx,ds:[02507754h]
00000163 call 740AF630


I am still unfortunately non the wiser about how to help my user.

Phil
 
Top