Re: "Global" exception handling

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Hello Tom,

What I forgot to write down in my first posting was: My UserControl is
part
of an own project and is hosted within the main application project.

try handle unhandled exeption in your mail app and this allow u to handle exeption even in other domains

u can find detailed info there http://msdn2.microsoft.com/en-us/library/system.appdomain.unhandledexception.aspx

---
WBR, Michael Nemtsev [.NET/C# MVP] :: blog: http://spaces.live.com/laflour

"The greatest danger for most of us is not that our aim is too high and we miss it, but that it is too low and we reach it" (c) Michelangelo


TB> Hi Michael,
TB> TB> I guess that was the right hint, thanks for the answer.
TB> TB> Unfortunately I have no experience and no idea working with
TB> AppDomain.
TB> TB> What I forgot to write down in my first posting was: My UserControl
TB> is part
TB> of an own project and is hosted within the main application
TB> project.
TB> I have no influence on the code of the host application so I can not
TB> force
TB> the developers to create an own AppDomain to run my assembly in.
TB> But can I do it for my own?
TB> In my UserControl constructor can I create an AppDomain from the
TB> scratch and
TB> can I assign my own current Assemby to that AppDomain and then
TB> handle
TB> UnhandledExceptions of this AppDomain?
TB> Is this the way you suggest?
TB> If so, how can I create a new AppDomain and assign my assembly?
TB> Thanks for your further help and sorry for my annoying newbie
TB> requests...
TB> TB> Tom
TB> TB> "Michael Nemtsev [MVP]" <nemtsev@xxxxxxx> schrieb im Newsbeitrag
TB> news:900895ec29b288ca36699c951d20@xxxxxxxxxxxxxxxxxxxxxxx
TB>
Hello Tom,

what are u handling now, is only exception on the application level,
without taking into account different appDomains
For this u need to add AppDomain.UnhandledException handlin'
---
WBR, Michael Nemtsev [.NET/C# MVP] :: blog:
http://spaces.live.com/laflour
"The greatest danger for most of us is not that our aim is too high
and we
miss it, but that it is too low and we reach it" (c) Michelangelo
TB> Just a short question concerning exception handling....
TB> TB> All of my applications contain an event handling in the
Main()
like
TB> this one:
TB> TB> [STAThread]
TB> static void Main()
TB> {
TB> // declare global exeption handler
TB> Application.ThreadException += new
TB>
ThreadExceptionEventHandler(GlobalExceptionHandler.OnThreadException
TB> );
TB> ...
TB> // load main form and start application
TB> ...
TB> }
TB> By that I am showing a special exception form to the user (with
TB> features like "send bug report to ..."). This is for cases where
I
TB> forgot a try/catch somewhere.
TB> TB> Now I have to write a UserControl for an application that is
out
of
TB> my
TB> control so I do not have personal influence on that code.
TB> My UserControl is just loaded by that application, user can do
TB> several
TB> things with it and it stays loaded all the time until the
TB> application is
TB> closed again.
TB> So the only entry point I have for this control is just the
TB> constructor.
TB> TB> How can I achieve to have a "global" exception handling just
for
my
TB> own UserControl code? With Application.ThreadException I would
TB> include also the hosting application...
TB> TB> Thanks in advance!
TB> Tom


.



Relevant Pages