运行后就提示:debug assertion failed
         File:afxwin1.inl
         Line:19  找到afxwin1.inl的19行内容是:
      _AFXWIN_INLINE HINSTANCE AFXAPI AfxGetInstanceHandle()
  {
               ASSERT(afxCurrentInstanceHandle != NULL);
return afxCurrentInstanceHandle; 
           } 请问这是什么问题,如何初始化实例,还是c#调用Csocket的问题,望高手帮忙,急!C++:extern "C" _declspec(dllexport) int InitVideoSDK(HWND pWnd)
{
int i;
SetTimer(pWnd,  1,1000,(TIMERPROC)TimerProc);//用回调函数处理
for(i=0; i<MAX_CAMERA_NUM; i++)
theApp.dvideo[i].CreateSocket(PORT_VIDEO,TYPE_VIDEO);
return 0;
}C#:[DllImport("lib_camera.dll")]
public static extern int InitVideoSDK(IntPtr pWnd); private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                InitVideoSDK(hwnd);
            }
            catch (System .Exception ex)
            {
                MessageBox.Show(ex.Message);
            }        }C#C++dll

解决方案 »

  1.   

    把要调用的C++dll拷贝到编译目录下
    添加引用:
    using System.Runtime.InteropServices;声明:
    [DllImport("lib_camera.dll" EntryPoint="InitVideoSDK")]
    public static extern int InitVideoSDK(IntPtr pWnd);private void button1_Click(object sender, EventArgs e)
            {
                try
                {
                    InitVideoSDK(this.Handle);
                }
                catch (System .Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }        }
    应该可以了,还不行联系我 qq:971096915
      

  2.   

    运行后就提示:debug assertion failed
             File:afxwin1.inl
             Line:19  这个应该不是MessageBox.Show(ex.Message)显示出来的,应该是C++内部的错误;
      

  3.   


    extern "C" _declspec(dllexport) int InitVideoSDK(HWND pWnd)
    {
      AFX_MANAGE_STATE(AfxGetStaticModuleState()); // <-- 加这行试试看
      int i;