How can I handle the exception which throws on an external dll?

后端 未结 4 642
北海茫月
北海茫月 2021-01-18 03:50

I have developed a project which uses an external dll as FTPServer, I have created the FTP Server on my project like this:

private ClsFTPServer _ClsFTPServer;

4条回答
  •  耶瑟儿~
    2021-01-18 04:16

    By putting a try...catch block around every call into the object and its methods.

    Something like:

    try
    {
        // use the DLL in some way
    }
    catch (Exception e) 
    {
        // Handle the exception, maybe display a warning, log an event, etc.)
    }
    

    Also note that while running under Visual Studio, if you go to the "Debug" menu and select "Exceptions..." it will allow the debugger to break on ALL exceptions if you start your program under the debugger, and not just unhandled exceptions. Just click the 'Thrown' checkbox next to "Common Language Runtime Exceptions".

提交回复
热议问题