tags:

views:

598

answers:

5

Hi Everyone,

I had the 32 bit dll which is written using Native C, when I tried compiling with VC++(VS2008) for converting the dll to x64 by changing the platform it compiled. But when I tried to access the dll from my C# application which is also 'x64' platform it fails to load the dll. I used Dllimport for linking the dll with my application.

The operating system I use in Vista, But I couldnt able to call the at dll function from my application it says failed to load the dll.

Is there any way to resolve this issue.

Looking forward from your help.

Regards, Ga

A: 

My guess would be dependencies, your new DLL may have some missing 64-bit DLL's that it needs.

Anders K.
when I checked using dependency walker its not showing any dependency for this dll. So I couldnt guess what is the problem over here.
Ganesh Astroved
what error code do you get when it fails to load?Try as an experiment write a small c++x64 program to load the DLL to see if that works just to see if the problem is in the DLL or some .NET issue.
Anders K.
A: 

try the tool "dependency walker" (ldd-like tool for win, www.dependencywalker.com) to find out what links against what. might be helpful.

felix
A: 

Check where you're building the different versions (x86/x64) of the dll to.

The easiest thing to do is set the target directory for the 64-bit dll to be a 'x64' subdirectory of your target folder. In your 64-bit solution configuration, set the C#'s target directory to also be the 'x64' directory.

This will ensure the exe for each platform tries to load the correct dll.

James Hopkin
A: 

Hi Everyone,

Thank for your help.

When I placed the dll under C:\Windows\System32\ the error resolved.

Thanks, Ga

Ganesh Astroved
So should you mark this as the answer?
kbyrd
A: 

I had a problem with this once along these lines. I had a C++ DLL that acted as an interface to a piece of hardware, that I needed to call from C#. However, it would fail the DllImport call if the piece of hardware was not plugged in. This is because the DLL initialisation function was returning a failure, so C# just said it couldn't load the DLL, it may not be to do with where the DLL is.

Check that you are not causing some sort of error when you are setting up the DLL in your C code.

Kazar