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.
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...
Boooya
Visual Studio 2008 Professional
Don't forget to use [CODE]your code here[/CODE] when posting code
Don't forget to rate helpful posts!
If you're question was answered please mark your thread [Resolved]
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.
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.
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?
Last edited by campster; Jul 17th, 2007 at 01:43 PM.
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
Last edited by bmahler; Jul 17th, 2007 at 03:10 PM.
Boooya
Visual Studio 2008 Professional
Don't forget to use [CODE]your code here[/CODE] when posting code
Don't forget to rate helpful posts!
If you're question was answered please mark your thread [Resolved]
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).
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.
Boooya
Visual Studio 2008 Professional
Don't forget to use [CODE]your code here[/CODE] when posting code
Don't forget to rate helpful posts!
If you're question was answered please mark your thread [Resolved]
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.
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.