RE: Can I throw an exception from my managed callback?
- From: nickdu <nicknospamdu@xxxxxxxxxxxxxxxx>
- Date: Mon, 6 Apr 2009 08:15:01 -0700
Thanks. It appears several of the links you provided don't work.
I did notice the docs for ProcessTrace() and was expecting to receive a
return of ERROR_NOACCESS when the callback threw an exception. However I
didn't. My managed callback threw an exception, didn't include any exception
handlers, and yet the return from ProcessTrace() was SUCCESS.
--
Thanks,
Nick
nicknospamdu@xxxxxxxxxxxxxxxx
remove "nospam" change community. to msn.com
"Lingzhi Sun [MSFT]" wrote:
Hi Nick,.
I am still performing research on the issue about how to make the
ProcessTrace API return corresponding error code, when managed callback
function throws an exception. I appreciate your patience. Besides,
could you please let me know the background information about why you want
the ProcessTrace API to return the error code? Maybe we can find other
workarounds which fit for your detailed concern. Here I'd like to discuss
this issue with you and provide you with a possible workaround.
Based on the MSDN documentation, if the native callback function throws an
exception, the ProcessTrace API returns ERROR_NOACCESS (Code: 998, Message:
Invalid access to memory location). For detail, please see
http://msdn.microsoft.com/en-us/library/aa364093.aspx and
http://msdn.microsoft.com/en-us/library/ms681388.aspx.
Based on my research on the managed codes, if the exception in managed
callback function is caught inside the callback function, the ProcessTrace
function returns zero (SUCCESS). If the managed callback function does
not catch the exception, the exception will be caught by the closest catch
block in the managed callstack.
If you want to deal with the managed exception correctly, you can use the
managed try/catch block to handle the exception. Here is a related blog
article, which contains a well-formed class EventTraceWatcher. You can
refer to this class on how to trace the ETW events in C#:
http://blogs.msdn.com/danielvl/archive/2009/02/02/how-to-consume-etw-events-
from-c.aspx.
If you have any other questions, please be free to let me know.
Regards,
Lingzhi Sun (v-micsun@xxxxxxxxxxxxxxxxxxxx, remove 'online.')
Microsoft Online Community Support
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
msdnmg@xxxxxxxxxxxxxx
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#notifications.
MSDN Managed Newsgroup support offering is for non-urgent issues where an
initial response from the community or a Microsoft Support Engineer within
2 business day is acceptable. Please note that each follow up response may
take approximately 2 business days as the support professional working with
you may need further investigation to reach the most efficient resolution.
The offering is not appropriate for situations that require urgent,
real-time or phone-based interactions. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/en-us/subscriptions/aa948874.aspx
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
- Follow-Ups:
- RE: Can I throw an exception from my managed callback?
- From: Lingzhi Sun [MSFT]
- RE: Can I throw an exception from my managed callback?
- References:
- Can I throw an exception from my managed callback?
- From: nickdu
- RE: Can I throw an exception from my managed callback?
- From: Lingzhi Sun [MSFT]
- Can I throw an exception from my managed callback?
- Prev by Date: RE: Can I throw an exception from my managed callback?
- Next by Date: Retrieving the COM class factory...error: 80040154.
- Previous by thread: RE: Can I throw an exception from my managed callback?
- Next by thread: RE: Can I throw an exception from my managed callback?
- Index(es):
Relevant Pages
|