简体   繁体   English

C#中的Microsoft Visual C ++运行时库异常

[英]Microsoft Visual C++ Runtime Library Exception in c#

I am using a fingerprint capture device in my c# application, this device has c# wrapper class for a c++ SDK dll. 我在c#应用程序中使用了指纹捕获设备,该设备具有用于c ++ SDK dll的c#包装器类。 Sometimes i get a c++ exception message (see image) and then the application close, the problem is that I can't catch this exception and can't keep application running after this exception. 有时我会收到一条c ++异常消息(参见图片),然后关闭应用程序,问题是我无法捕获此异常,并且在此异常之后无法保持应用程序运行。 The Question is: How Can I Catch This Exception in C#? 问题是:如何在C#中捕获此异常? 在此处输入图片说明

How Can I Catch This Exception in C#? 如何在C#中捕获此异常?

You cannot. 你不能。 An unmanaged C++ exception cannot be caught by managed code. 托管代码无法捕获非托管C ++异常。 You need to catch unmanaged exceptions in unmanaged code. 您需要在非托管代码中捕获非托管异常。 You cannot let unmanaged exceptions propagate outside the unmanaged module. 您不能让非托管异常传播到非托管模块之外。

However, the error dialog suggests that you have a more serious problem. 但是,错误对话框提示您有一个更严重的问题。 One that cannot be dealt with simply by catching an exception. 一个不能通过捕获异常来处理的事件。 You will need to work out why your program is terminating the runtime in this catastrophic way, and stop that happening. 您将需要弄清楚为什么您的程序以这种灾难性的方式终止运行时,并阻止这种情况的发生。 That error dialog suggests that your program is calling abort() , which is terminal. 该错误对话框表明您的程序正在调用abort() ,它是终端。

In other words you need to prevent this error from happening in the first place, rather than attempting to recover from it. 换句话说,您需要首先防止发生此错误,而不是尝试从中恢复。 This is not an error that you can hope to recover from. 这不是您可以希望从中恢复的错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM