Question

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

Was it helpful?

Solution

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

OTHER TIPS

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

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.

Thank for your help.

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

Thanks, Ga

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top