Why Is Detail Hidden In Private Fields In AccessViolationException

  • Thread starter Thread starter Tristan MSDN Keen
  • Start date Start date
T

Tristan MSDN Keen

I've written a test harness in C# to test one of our company's products,
which is written in C.

If the application crashes, the Instruction Address, Memory Address and the
Access Type are stored in the private fields _ip, _target and _accessType of
the AccessViolationException that is thrown. I want to be able to report
these errors to the user in the C# harness to assist in writing defect
reports for the development teams.

I can only access these fields using Reflection. My question is why is this
informative information kept in private fields in the exception, and not
available as a public Property? It would also seem to make sense for this
information to be reported in the Message property as well.

If the crash occurs when running the product directly, i.e. in C, this
information is reported by Windows, so it seems at first glance a step
backwards to not report this information when the AccessViolationException is
thrown from the P/Invoke.
 
I dont have any code which generates one of these but have you tried looking
in the Data property. Its a dictionary which is sometimes used to give extra
information about the exception.

Let us know if its in there.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top