I have a whole sequence of interlinked questions. I would like to know answers for all of them independantly, so *yes*, some of them appear to be X-Y questions; but I do want to know the solution to them anyway!. See end of question for list of other questions in this set.
I have a situation in which calling Marshal.GetExceptionForHR(code, pointers)
throws an AccessViolationException
.
Apparently this a VeryBadThing. So bad that try...catch
just shrugs at me and wanders off for a fag ... which I didn't know was a thing :(
Suppose a premise of "calling .GetExceptionForHR()
is what I want to do" (see other questions for a discussion of whether this is a good idea!).
Suppose further that whatever causes the AccessViolation
is unavoidable in some scenarios.
Given those premises, is there any way to predict in advance that calling them method will blow up?
Some equivalent of TryGetExceptionForHR()
that'll return false
rather than blowing up my entire Program.
Other questions in this problem set.
- C#: How do I prevent a pipe reading error, when closing the exe on one end of a DuplexChannel connected by Named Pipes?
- Ascertain reason for Channel Fault in WCF+NamedPipes
- Is using the `Marshal` static class in otherwise normal C# code unwise?
- Is there a way to predict that `Marshal.GetExceptionForHR(code, pointers)` would throw an `AccessViolationException`
- Is this a suitable use of `HandleProcessCorruptedStateExceptions`