System.BadImageFormatException.. What is the problem?

M

Madhu Gopinathan

Hi,
I am facing a problem in .NET COM InterOp. I have a COM Dll which I want to use from my CSharp code. So, I import the TLB directly from the DLL using the tlbimp tool to a managed DLL. I add a reference to this managed DLL in my CSharp solution. Now, when I try to create a new instance of an object inherent in the COM DLL using

MyObject object = new MyObject();

I recieve the error,

An unhandled exception of type 'System.BadImageFormatException' occurred in TestInterOp.exe.
Additional information: Exception from HRESULT: 0x800700C1.

What is the problem here? I have added the managed assembly to the GAC because I don't want to do that.

Regards,
Madhu.
 
D

Dave

Did you sign the assembly with a strong name?
Hi,
I am facing a problem in .NET COM InterOp. I have a COM Dll which I want to use from my CSharp code. So, I import the TLB directly from the DLL using the tlbimp tool to a managed DLL. I add a reference to this managed DLL in my CSharp solution. Now, when I try to create a new instance of an object inherent in the COM DLL using

MyObject object = new MyObject();

I recieve the error,

An unhandled exception of type 'System.BadImageFormatException' occurred in TestInterOp.exe.
Additional information: Exception from HRESULT: 0x800700C1.

What is the problem here? I have added the managed assembly to the GAC because I don't want to do that.

Regards,
Madhu.
 
M

Madhu Gopinathan

Hi Dave,
Yes, I tried signing the assembly with a strong name as well. Still the error persisted. The code works if I add a reference to the COM DLL directly without having to go through the assembly.

Regards,
Madhu
 
D

Dave

You might try looking in the fusion log to see if the clr had trouble locating the assembly. Perhaps the reported exception isn't the true source of the problem.
Hi Dave,
Yes, I tried signing the assembly with a strong name as well. Still the error persisted. The code works if I add a reference to the COM DLL directly without having to go through the assembly.

Regards,
Madhu
 

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