Share via


32 bit dll reference to 64 bit application

Question

Monday, May 23, 2016 5:13 PM

Hi,

We have a legacy dll which built in x86 (32 bit). We have to take reference to a x64 (64 bit) application.

I am able to add the reference of 32bit dll to 64bit applicaiton and able to access all the methods in the dll. There are no build errors while we build the 64bit solution. But when I run the application, I got the below exception.

Please help me to resolve the issue and able to access the 32bit dll methods from 64bit applicaiton.

Thanks & Regards
Naga Suresh D

All replies (15)

Monday, May 23, 2016 5:52 PM | 1 vote

Probably not a Microsoft .Net dll but something from AIMS 360

Maybe can you contact them.

http://www.aims360.com/product/aims-360-software/

Success
Cor


Monday, May 23, 2016 5:58 PM

This is the expected behavior when referencing a DLL with 32Bit components or features:

BadImageFormatException Class:

"A DLL or executable is loaded as a 64-bit assembly, but it contains 32-bit features or resources. For example, it relies on COM interop or calls methods in a 32-bit dynamic link library.

To address this exception, set the project's Platform target property to x86 (instead of x64 or AnyCPU) and recompile."

You will need to compile your application as 32Bit, or get a 64Bit version of the DLL in question.

Reed Kimble - "When you do things right, people won't be sure you've done anything at all"


Monday, May 23, 2016 6:20 PM | 1 vote

You will need to compile your application as 32Bit, or get a 64Bit version of the DLL in question.

Another option is to load the DLL into a 32 bit host/wrapper executable and then to link the DLL to the 64 bits application via a IPC method of your choice.

Luc


Monday, May 23, 2016 6:33 PM

Another option is to wrap the DLL into a 32 bit host/wrapper executable and then to link the DLL to the 64 bits application via a IPC method of your choice.

Luc

Very creative Luc.  :) 

Reed Kimble - "When you do things right, people won't be sure you've done anything at all"


Monday, May 23, 2016 7:20 PM | 1 vote

Can you change the Platform of the legacy DLL project to Any CPU? I'm assuming it's a .NET DLL.

Unless the legacy DLL is dependent upon a 32-bit API I don't see any reason why you couldn't change it to support both 32 and 64-bit implementations.

Paul ~~~~ Microsoft MVP (Visual Basic)


Monday, May 23, 2016 7:27 PM | 1 vote

No one of you did probably check what AIMS 360 is. I did. Look at my message for an idea. 

The DLL can be anything and of any format.

 

Success
Cor


Monday, May 23, 2016 7:55 PM

No one of you did probably check what AIMS 360 is. I did. Look at my message for an idea. 

The DLL can be anything and of any format.

 

Success
Cor

I did. Also if Naga needs to contact AIMS 360 there probably will not be far to go if Naga works there Naga Suresh AIMS360.

La vida loca


Monday, May 23, 2016 9:43 PM

I did. Also if Naga needs to contact AIMS 360 there probably will not be far to go if Naga works there Naga Suresh AIMS360.

Yea I missed that one.

Success
Cor


Tuesday, May 31, 2016 3:28 PM

I think the question was not convayed correctly. Apologies for the misunderstand the issue.

Actually our issue is.....

We have a 32 bit .Net dll and 64 bit .Net WPF application.

We have to take the 32 bit .Net dll reference to 64 bit .Net WPF application. Reference is adding and no build errors.

But while executing the 64 bit application, we are getting the exception (Which I posted in earlier).

For testing purpose, we have created a 32 bit dll with name "AIMS360VFPClassLibrary". It is not a production dll.

Hope you can understand my issue.

Please help us to resolve the 32 V/S 64 bit compactability issues.

Thanks & Regards
Naga Suresh D


Tuesday, May 31, 2016 3:49 PM | 1 vote

I think the question was not convayed correctly. Apologies for the misunderstand the issue.

Actually our issue is.....

We have a 32 bit .Net dll and 64 bit .Net WPF application.

We have to take the 32 bit .Net dll reference to 64 bit .Net WPF application. Reference is adding and no build errors.

But while executing the 64 bit application, we are getting the exception (Which I posted in earlier).

For testing purpose, we have created a 32 bit dll with name "AIMS360VFPClassLibrary". It is not a production dll.

Hope you can understand my issue.

Please help us to resolve the 32 V/S 64 bit compactability issues.

Thanks & Regards
Naga Suresh D

You need to do what Crazypennie mentioned in his post.

Accessing 32-bit DLLs from 64-bit code

The Best Way to Use a 32-Bit DLL Library in a 64-Bit Platform

Or buy something like below but only works with unmanaged code DLLs currently.

You just found DLLWrapper! - A tool to wrap 32 bit DLLs as 64 bit DLLs and vice versa.

La vida loca


Tuesday, May 31, 2016 4:06 PM | 1 vote

@John (mrM),

I tried also some things and searched also, I did not find that wrapper tool and probably like you I don't know if it is the solution. 

After searching I took the conclusion that to do this would be without that something what I always call "Blood, sweat and tears solutions". Like I said, I don't know if that DLLWrapper functions.

:-)

Success
Cor


Tuesday, May 31, 2016 4:17 PM

@John (mrM),

I tried also some things and searched also, I did not find that wrapper tool and probably like you I don't know if it is the solution. 

After searching I took the conclusion that to do this would be without that something what I always call "Blood, sweat and tears solutions". Like I said, I don't know if that DLLWrapper functions.

:-)

Success
Cor

No doubt regarding "Blood, sweat and tears solutions". Probably OP should find Decompiler that can decompile legacy .Dll then recreate same in .Net and compile to 64 bit I suppose. OP don't mention what legacy .Dll was written in otherwise I may have been able to provide link(s) to decompiler for same.

La vida loca


Tuesday, May 31, 2016 8:28 PM | 1 vote

Why is your DLL 32-bit? Is it because it's dependent upon a 32-bit library that you cannot change?

The easiest way to handle this is to either create a 32-bit ActiveX EXE (using VB 6) or to configure your 32-bit DLL to run under COM+.

Paul ~~~~ Microsoft MVP (Visual Basic)


Tuesday, May 31, 2016 9:49 PM

Why is your DLL 32-bit? Is it because it's dependent upon a 32-bit library that you cannot change?

The easiest way to handle this is to either create a 32-bit ActiveX EXE (using VB 6) or to configure your 32-bit DLL to run under COM+.

Paul ~~~~ Microsoft MVP (Visual Basic)

Paul,

Even I can guess that, the class has in its name VFP, so this is most probably a try to to wrap VFP into a Net application. But maybe you can help him with that. It is in fact your specialty.

Success
Cor


Tuesday, May 31, 2016 10:16 PM

Why is your DLL 32-bit? Is it because it's dependent upon a 32-bit library that you cannot change?

The easiest way to handle this is to either create a 32-bit ActiveX EXE (using VB 6) or to configure your 32-bit DLL to run under COM+.

Paul ~~~~ Microsoft MVP (Visual Basic)

Paul,

Even I can guess that, the class has in its name VFP, so this is most probably a try to to wrap VFP into a Net application. But maybe you can help him with that. It is in fact your specialty.

Success
Cor

Cor,

Yeah, I thought maybe Visual FoxPro and I don't believe there are any 64-bit drivers for that database. The VFP database technology is kaput as far as Microsoft is concerned.

Paul ~~~~ Microsoft MVP (Visual Basic)