我怎么能处理这个异常的外部DLL抛出? [英] How i can handle the exception throws on an external dll?

查看:296
本文介绍了我怎么能处理这个异常的外部DLL抛出?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经开发出使用外部DLL作为FTPServer的一个项目,我创建FTP服务器上我的项目是这样的:

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

私人ClsFTPServer _ClsFTPServer;结果
_ClsFTPServer =新ClsFTPServer(FTPUserName,FTPPassword,FTPPath);

上面的代码创建一个实例FTP服务器类,该类开始的FTPServer它的构造,它独立工作正常作为一个模块,而客户端正确发送thier要求,但是,当一个不正确的请求到达FTP服务器时,它抛出一个异常,并导致我的应用程序崩溃。

The Code above creates an instance of FTP server class, the class starts the FTPserver on it's constructor, it works fine independently as a module while the clients send thier request correctly, but when an incorrect request comes to FTP server it throws an exception and cause my application to crash.

如何处理由外部DLL抛给崩溃pervent我的应用程序了异常?

How I can handle the exception thrown by the external dll to pervent my applicaiton from crashing?

推荐答案

我最近回答了一个类似(ISH)问题,这可能证明是有用的 -
赶上完全意外的错误

I recently answered a similar (ish) question which may prove useful - Catch completely unexpected error

编辑。我有一个以上的汉斯的评论同意。 - <一个 - 可能是一个想法,找到另一个FTP服务器

EDIT. I have to agree with Hans' comment above - might be an idea to find another FTP server.

只是为了完整性,这里是从应用程序域/线程例外设置HREF =http://msdn.microsoft.com/en-GB/library/system.windows.forms.application.threadexception.aspx相对=nofollow> http://msdn.microsoft.com/en-GB /library/system.windows.forms.application.threadexception.aspx

Just for completeness, here's the appdomain/thread exception setup from - http://msdn.microsoft.com/en-GB/library/system.windows.forms.application.threadexception.aspx

Application.ThreadException += new ThreadExceptionEventHandler  (ErrorHandlerForm.Form1_UIThreadException);

// Set the unhandled exception mode to force all Windows Forms errors to go through 
// our handler.
Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);

// Add the event handler for handling non-UI thread exceptions to the event. 
AppDomain.CurrentDomain.UnhandledException +=
    new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);

这篇关于我怎么能处理这个异常的外部DLL抛出?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆