I have a c++ dll and c# application. In C# application I call function from dll. With simple function like:
extern "C"
{
__declspec(dllexport) void HelloFromDll()
{
MessageBox(NULL, _T("Hello from DLL"), _T("Hello from DLL"), NULL);
}
}
all works fine. When i use function with glut like this:
extern "C"
{
__declspec(dllexport) int InitGlut()
{
glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA);
glutInitWindowPosition(100,100);
glutInitWindowSize(320,320);
glutCreateWindow("MyWindow");
glutDisplayFunc(renderScene);
glutMainLoop();
return 0;
}
}
i get DllNotFound Exception. Why? C# code:
const string pathToDll = "../../../Release/MyDLL.dll";
[DllImport(pathToDll)]
public static extern void HelloFromDll();
[DllImport(pathToDll)]
public static extern int InitGlut();
private void Window_Loaded(object sender, RoutedEventArgs e)
{
HelloFromDll();
InitGlut();
}
Set your working directory of your application to the path of the DLL's, this should solve your problem.