Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Win 7 DllImport C# Odd error, Invalid access to memory location?

Tags:

c#

dllimport

I am using DllImport to access some functions in a C++ dll from my C# application.

This code works fine on my dev laptop, which is Windows 7 64bit, the dll itself is 32 bit, so I run the process hosting the dll in 32bit and it works well. However when I try to run the exact same process on my target machine, which is again, Windows 7 64bit Ultimate i get the error 'Invalid access to memory location.' from the process.

I'm not sure what the problem is, i've looked at loads of resources on the net and none of them have solved it for me. I dont understand why it works fine on my dev box, but not on the target?

The dll itself is fine, the examples that come with the dll all work fine on my target box (which are C# apps doing DllImport).

Has anyone else had this problem? Been fighting it for two days now!

Exception: {"Unable to load DLL 'CLEyeMulticam.dll': Invalid access to memory location. (Exception from HRESULT: 0x800703E6)"}

like image 711
James Avatar asked Jul 24 '10 22:07

James


1 Answers

The DLL loading may crash because of unresolved dependencies, so open your DLL on target machine using Dependency Walker and see is there any problems.

like image 153
Jarlaxle Avatar answered Nov 15 '22 00:11

Jarlaxle