[RESOLVED] [2005] Referencing C++ DLL
I am having problems referencing a C++ DLL from my .Net App. Everything works fine onthe machine that I build the app but if I try to run the app on a different machine I get an error:
Could not load file or assembly 'AClassLib'.
I've simplified the app and DLL down to 2 functions. What am I missing?
vb Code:
Imports AClassLib
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'Dim ACL As AClassLib.Class1 = New AClassLib.Class1
Dim ACL As New AClassLib.Class1
Dim a As Double
Dim b As Double
Dim c As Double
a = TextBox1.Text
b = TextBox2.Text
Try
c = ACL.AddEm(a, b)
Catch ex As Exception
MessageBox.Show("Button1_Click: " & ex.Message.ToString)
End Try
lblAnswer.Text = c
End Sub
End Class
Code:
#include "stdafx.h"
#include "AClassLib.h"
namespace AClassLib {
double Class1::AddEm(double A, double B)
{
return A + B;
}
}
Re: [2005] Referencing C++ DLL
It appears that you need to install a redistribution app to use the C++ DLL. The app is
C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\BootStrapper\Packages\vcredist_x86\vcredist_x86.exe
Does anyone know why this application is required?
Re: [2005] Referencing C++ DLL
you need to declare the function for the c++ dll. Just like declaring for API
vb.net Code:
Public Declare Function AddEm Lib "DLLName.dll" (ByVal A As Double, ByVal B As Double) As Double
obviously replace DLLName.dll with the name of your dll.
If you declare the function you can then call it from code. The c++ dll needs to be either in the application directory or the system32 directory
Re: [2005] Referencing C++ DLL
Quote:
you need to declare the function for the c++ dll. Just like declaring for API
I tried that and it didn't work. I had to install the redistribtion application and everything is fine. I'mreading MSDN now about dll Manifests
http://msdn2.microsoft.com/en-us/lib...42(vs.80).aspx
Re: [2005] Referencing C++ DLL
Found the problem. Some of the other libraries that were being included in the main application was built as debug versus release. The dll could not resolve the debug functions and was crashing. Until we get release versions of the libraries we had to put debug versions of the CRT (msvcm80d,msvcp80d and msvcr80d) in the directory with our DLL.