DlgTest.dll动态库部分代码: 1、DlgTest.cpp#include "Win32TestDlg.h" void _FrameFindApplicationDLG() { CWin32TestDlg dlg; dlg.DoModal();} ......2、DlgTest.def _FrameFindApplicationDLG() @13、Win32TestDlg.h和Win32TestDlg.cpp中什么也没做测试: 1、创建了一个VC 对话框exe程序,动态加载此动态库,调用函数,成功! 2、创建一个.Net程序,C#编写,部分代码如下: using System.Runtime.InteropServices;//这是用到DllImport时候要引入的包[DllImport("DlgTest.dll",CharSet=CharSet.Auto)] static extern void _FrameFindApplicationDLG();private void button1_Click(object sender, System.EventArgs e) { _FrameFindApplicationDLG(); } 出错:Debug Assertion Failed! Program:E:\DllTest\bin\Debug\DllTest.exe File:afxwin1.inl Line:22 For information on how your program can cause an assertion faiure,see the visual C++ document on asserts. (Press Retry to debug the application)
动态库里就是插入一个对话框,上面什么也没有,创建一个对应类,然后在app里写一个全局函数,让对话框类DoModal().在.def里输出这个函数.别的什么也没做.动态库是基于扩展MFC的.
C#:p/Invoke方法
DllImport[]
......
应该调用过程没错.
楼上的老兄如果能够写个测试代码发给[email protected],非常感谢!
B动态库是弹出一个对话框.不知道有什么限制....
1、DlgTest.cpp#include "Win32TestDlg.h" void _FrameFindApplicationDLG()
{
CWin32TestDlg dlg;
dlg.DoModal();}
......2、DlgTest.def _FrameFindApplicationDLG() @13、Win32TestDlg.h和Win32TestDlg.cpp中什么也没做测试:
1、创建了一个VC 对话框exe程序,动态加载此动态库,调用函数,成功!
2、创建一个.Net程序,C#编写,部分代码如下:
using System.Runtime.InteropServices;//这是用到DllImport时候要引入的包[DllImport("DlgTest.dll",CharSet=CharSet.Auto)]
static extern void _FrameFindApplicationDLG();private void button1_Click(object sender, System.EventArgs e)
{
_FrameFindApplicationDLG();
}
出错:Debug Assertion Failed!
Program:E:\DllTest\bin\Debug\DllTest.exe
File:afxwin1.inl
Line:22
For information on how your program can cause an assertion
faiure,see the visual C++ document on asserts.
(Press Retry to debug the application)
A就是没添加任何资源,直接写了个加法函数,输出.
就这些区别.
哪位兄弟能写个简单的显示对话框的动态库
然后C#调用,把成功的简单代码象上面一样贴一下?
谢谢!!!!