使用 DLLImport 时异常如何工作
How Do Exceptions Work When Using DLLImport
我正在使用DLLImport从C#应用程序调用GhostScript库。
所以我有一些这样的代码,
[DllImport("gsdll32.dll", EntryPoint = "gsapi_init_with_args")]
private static extern int gsapi_init_with_args(IntPtr instance, int argc, IntPtr argv);
try
{
intReturn = gsapi_init_with_args(intGSInstanceHandle, intElementCount, intptrArgs);
}
catch (Exception ex)
{
throw new ApplicationException(ex.Message, ex);
}
我将查看用 C 或 C++ 编写的 GhostScript 源代码,但总的来说,我想知道如果 GhostScript 代码抛出未经处理的异常会发生什么?会被那里的渔获抓住,还是必须看起来像这样,
catch
{
// blah
}
它不会引发异常,您应该查看返回代码。http://pages.cs.wisc.edu/~ghost/doc/AFPL/7.04/API.htm#return_codes
C 编程的标准方法,返回错误的非零代码,有时后跟第二个 API 调用以检索错误的更多详细信息。
相关文章:
- QSqlquery prepare()和bindvalue()不工作
- 导入库可以跨dll版本工作吗
- 以螺旋方式打印矩阵的程序.(工作不好)
- 对象指针在c++中是如何工作的
- 为什么在Windows上的VS 2019和Clang 9中"size_t"在没有标题的情况下工作
- VSOMEIP-2个设备之间的通信(TCP/UDP)不工作
- 为字符串中每 N 个字符插入空格的函数没有按照我认为的方式工作?
- C++为线程工作动态地分割例程
- 为什么我的 std::ref 无法按预期工作?
- 布尔比较运算符是如何在C++中工作的
- SampleConsensusPrerejective(ext.RANSAC)是如何真正工作的
- 不确定要在我的main中放入什么才能使我的代码正常工作
- 为什么std::condition_variable notify_all的工作速度比notify_one快(对于随机请
- <<操作员在下面的行中工作
- 有人能解释一下为什么下界是这样工作的吗C++的
- ExtractIconEx:可以工作,但偶尔会崩溃
- C++中的memset函数工作不正常
- 当我在第一个循环中使用"auto"时,它工作正常,但是使用"int"它会给出错误,为什么?
- 当 int 方法工作正常时,void 方法有何不同,或者为什么我不能调用 void 方法?
- sdl软件渲染器不工作,工作在硬件加速的一个