I am using DLLImport to call the GhostScript library from a C# application.
So I have some code like this,
[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);
}
I am going to look at the GhostScript source code, which is written in C or C++, but in general I was wondering what would happen if the GhostScript code threw an unhandled exception? Would that be caught by the catch there, or would it have to look like this,
catch
{
// blah
}
It won't throw an exception, you're meant to look at the return codes. http://pages.cs.wisc.edu/~ghost/doc/AFPL/7.04/API.htm#return_codes
Pretty standard method for C programming, return code of non zero for an error, sometimes followed by a 2nd API call to retrieve more details of the error.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With