7
Reply

Unable to load DL

Jenn Huynh

Jenn Huynh

Apr 2 2008 2:49 PM
16.8k

Hello Everyone,

I have a window application that written in C# and I want to use one of the dll file from the API c/c++ to my window project.  I use the P/Invoke to import the dll file and I initialize the declaration of each function call afterward.  In the code below, I have a function to read the access database and it returns 2 values, so I use those 2 values to pass parameter to one of the function call in the dll, but when it reaches to the Init();  function, it fails because of "Unable to load DLL 'elevation.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E) ",  I put the elevation.dll and all its related dll/files to the bin folder. I try serveral ways that I could find the answer on web to solve this problem, but unsuccessful.  I'm hoping anyone in here knows this problem and help me to solve it? I'm really aprreciated and thankyou.

I develope this application in Visual Studio 2005 and below is my DllImport and a function call:

[DllImport("elevation.dll", SetLastError = true)]

private static extern void Init();

[DllImport("elevation.dll", SetLastError = true)]

private static extern bool GetElevation(double dLat, double dLon, ref double dHeight);

 

//Read .mdb to get the  Latitude and Longitude, and pass 2 value parameter to the "GetElevation" function.

while (myReader.Read())

{

Latitude = Convert.ToDouble((myReader["lat"] + ""));

Longitude = Convert.ToDouble((myReader["longi"] + ""));

Init();                         //Failed to load the elevation.dll at the Init(); function

GetElevation(Latitude, Longitude, ref dHeight)

}


Answers (7)