我有一個C++ DLL和C#應用程序。在C#應用程序中,我從dll調用函數。 通過簡單的功能,如:DllNotFound異常,當我在我的Dll中使用過剩功能
extern "C"
{
__declspec(dllexport) void HelloFromDll()
{
MessageBox(NULL, _T("Hello from DLL"), _T("Hello from DLL"), NULL);
}
}
一切工作正常。 當我使用功能與過剩是這樣的:
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;
}
}
我得到DllNotFound例外。爲什麼? C#代碼:
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();
}
請驗證答案。 – 2011-04-24 15:34:27