[RESOLVED] [2005] Trouble Loading DLL
I have a C++ DLL that was written by a co-worker. My app accesses this DLL fine on my development machine (running VS2005). If I move this app and DLL pair to another machine with 2005 installed everything works but I get an error that the DLL failed to load if I try to run it on a machine that does not have 2005 installed.
I have already ran the vcredist.exe on the test machine. I am placing the DLL in the same folder as the executable.
I'm not a work but I will post the actual error message as soon as I get there.
1 Attachment(s)
Re: [2005] Trouble Loading DLL
Re: [2005] Trouble Loading DLL
How are you referencing the dll?
1 Attachment(s)
Re: [2005] Trouble Loading DLL
using the Add button on the reference tab.
Re: [2005] Trouble Loading DLL
hmmm, I have never had any lcuk adding C++ dll's like that. I am not saying that it doesn't work, but I have always referenced them like using API's with the System.Runtime.InteropServices namespace. You might want to look into trying it that way using <DllImport etc...
Re: [2005] Trouble Loading DLL
Thanks for the help. I'll look into it but why would my way work on some machines and not others? I haven't proven the VS2005 dependency yet but it sure seems like the exe and dll work on any amchine with 2005 and bombs otherwise.
I was on my last leg of testing for a July 1st deadline when I ran into this. Oops, looks like things are shifting to the right a little.
Re: [2005] Trouble Loading DLL
after you add the reference.... did it create a file with the dll name and Interop in it? Make sure you send that file along as part of the installation. it's a wrapper that allows the .NET app to talk to the DLL properly. On the development machine it works because, well, the file was created there.
-tg
Re: [2005] Trouble Loading DLL
Quote:
did it create a file with the dll name and Interop in it?
Did it? Shrug shrug.. Where would this file be located?
Quote:
On the development machine it works because, well, the file was created there
It works on machines other than the developement machine as long a that machine has VS2005 installed. I'm soooo confused.
Re: [2005] Trouble Loading DLL
I'm trying the method described by bmahler but am having problems. The methods that I'm trying to use are within a class the I usally declare like this:
Code:
Private SimIFace As SimIFaceNET
and use like this
vb Code:
SimIFace = New SimIFaceNET
stat = SimIFace.Connect()
If stat = 0 Then
SimIFace.SetExamMode(1)
End If
I've deleted the reference from the reference table and added the declarations to my code like this:
vb Code:
Private Declare Function Connect Lib "OpenSimNET.dll" () As Integer
Private Declare Function SetExamMode Lib "OpenSimNET.dll" (ByVal mode As Integer) As Integer
or like this
vb Code:
<DllImport("OpenSimNET.dll")> _
Public Shared Function Connect() As Integer
End Function
<DllImport("OpenSimNET.dll")> _
Public Shared Function SetExamMode(ByVal mode As Integer) As Integer
End Function
And I've now make the call like this:
vb Code:
'SimIFace = New SimIFaceNET
'stat = SimIFace.Connect()
stat = Connect()
If stat = 0 Then
'SimIFace.SetExamMode(0)
SetExamMode(0)
End If
Everything compiles but when I try to access the Connect method I get an EntryPointNotFound Exception. How would I make an instance of this class using the Declare statements?
Re: [2005] Trouble Loading DLL
Check out this tutorial on codeproject. It is dealing wiht C# but it runs into the same issues you are having and has some good explanations.
http://www.codeproject.com/csharp/unmanage.asp
I don't know if you have the ability to modify the cpp dll or not but it looks like the Extern functions need to have a "C" at the beginning to tell the coompiler to not decorate the functions.
If you can't change the dll you can get the export functions by calling this
dumpbin -exports path_to_dll
This will give you the correct export names and then you can set the entrypoint like so
Code:
<DllImport("OpenSimNET.dll", EntryPoint:="FUNCTION NAME FROM dumpbin -exports")> _
Public Shared Function Connect() As Integer
End Function
1 Attachment(s)
Re: [2005] Trouble Loading DLL
Unless I'm missing something the DLL is not exporting the functions that I'm looking for. This is a dump that I took about an hour ago. I thought that I was doing something wrong and moved on to something else (which isn't working).
Re: [2005] Trouble Loading DLL
well it looks like the dll was not made in such a way that it is exporting the functions.
Perhaps this is another issue.
This just came to me... Do the machines you are trying to run it on that do not have VS installed have the C runtime dlls? if they are not present then the dll will not work. then one sI can think of off the top of my head are
msvcr70.dll
msvcr71.dll
msvcp70.dll
msvcp71.dll
and I am sure that there are more.
I had an app that used these and I had to include them in the installer because many machines do not already have them.
Re: [2005] Trouble Loading DLL
I'm sure that the machines do not have those DLLs but I ran the VCREDIST.exe file on at least one test machine and the problem is still there. I believe that VCREDIST should install all of the required CRTs.
http://www.microsoft.com/downloads/d...displaylang=en
Another interesting thing is that I installed VS2005 on another test machine and the dll won't load there either. There goes the idea that it's based on the installation of VS2005.
Re: [2005] Trouble Loading DLL
You've got to be ^@$%%@% kidding me!!!!
The problem was the CRT libraries. Evidently you need the vcredist SP1 versus vcredist.
Here's the link if anyone needs it.
http://www.microsoft.com/downloads/d...displaylang=en
Thanks for the help.