I am writing a C # .NET 3.5 program that uses the latest MediaInfoLib Dll .
This seems to cause exceptions for some files.
I want to catch these exceptions and ensure that my program continues to work,
but for some reason I can't catch it with a simple try / catch statement.
PInvoke Methods:
[DllImport("MediaInfo.dll")] private static extern IntPtr MediaInfo_New(); [DllImport("MediaInfo.dll")] private static extern IntPtr MediaInfo_Open(IntPtr Handle,MarshalAs(UnmanagedType.LPWStr)] string FileName);
Using:
Handle = MediaInfo_New(); try{ MediaInfo_Open(Handle, FileName) } catch { }
A call to MediaInfo_Open (Handle, FileName) may throw an exception.
Instead of catching the error using the try / catch statement, my program exits and "vshost32-clr2.exe" crashes. (It also crashes as a release build and without a debugger)
After searching the Internet, I found someone who suggested checking "Enable unmanaged code debugging", which only led to the exit of my program without breaking vshost32-clr2.exe.
Any idea how I can catch the exception?
Arokh
source share