请问捕捉到异常后怎么处理,能使这个dll重新载入使函数能再次使用 
No, you can't.

解决方案 »

  1.   

    看来楼主用的ocr呢
    有没有释放的函数呢?应该有的吧,我调用汉王的ocr都有函数释放的
      

  2.   

    释放也是dll本身的接口函数
    本身dll已经死了,释放也没有用了我就是想找到一种能类似程序关闭又打开的方法
      

  3.   


    If you have to, try creating an AppDomain and then run the P/Invoke within that domain.
    You have to unload the whole domain to free loaded dlls.
      

  4.   

    i'm just a beginner and i started wrote code 3 days ago, can you tell me the way how to use AppDomain for those codes? 
    i've search the way in internet for long time, i'm still confusing, thanks.
      

  5.   

    有谁能指点下把这段代码转换成appDomain的形式呢?[DllImport("AdvOcr.dll", EntryPoint = "OCR_C", SetLastError = true, 
                CharSet = CharSet.Ansi, ExactSpelling = true, 
                  CallingConvention = CallingConvention.StdCall)]         protected static extern string OCR_C(string type, string fileName); 
            while(true){ 
                      try { 
                        string result = OCR_C(OCR_type, filePath);                   } 
                      catch { 
                        
                          MessageBox.Show("出错了!");                 
                      } 
                    }
      

  6.   


    上述的尝试并不能成功 - 刚才的试验表明本地dll并没有随着AppDomain卸载而卸载。
    我也不建议显式用LoadLibrary,GetProcAddress和FreeLibrary。回过头来,你的问题在Dll方面,掩盖问题会使以后的开发和维护变得更难。
    要在项目开始时选择好的第三方模块,而不要在开发和维护过程中不断擦别人的屁股。
      

  7.   

    原来这里已经解决:http://topic.csdn.net/t/20050609/15/4070992.html