Hi,
I would like to create some mechanism to handle all the exceptions
which will happen in my application.
I have one form which is the base form while all the other forms
inherit from it.
I try to find a way to "register" the base form to the Error handling
, but I don't know how….
Basically I'm try to catch an exceptions which occur in form2 (which
inherit from form1) through and exception handling which I will
implement through form1.
If any one has any idea, please let me know.
Thanks,
Ori. 7 17700
Ori,
Depending on the type of application you are creating, .NET has three
different global exception handlers.
For ASP.NET look at:
System.Web.HttpApplication.Error event
Normally placed in your Global.asax file.
For console applications look at:
System.AppDomain.UnhandledException event
Use AddHandler in your Sub Main.
For Windows Forms look at:
System.Windows.Forms.Application.ThreadException event
Use AddHandler in your Sub Main.
Hope this helps
Jay
"Ori" <or*******@hotmail.com> wrote in message
news:b4*************************@posting.google.co m... Hi,
I would like to create some mechanism to handle all the exceptions which will happen in my application.
I have one form which is the base form while all the other forms inherit from it.
I try to find a way to "register" the base form to the Error handling , but I don't know how..
Basically I'm try to catch an exceptions which occur in form2 (which inherit from form1) through and exception handling which I will implement through form1.
If any one has any idea, please let me know.
Thanks,
Ori.
Check out the Application.ThreadException http://tinyurl.com/2upm9
Remarks
This event allows your Windows Forms application to handle otherwise
unhandled exceptions. Attach your event handlers to the ThreadException
event to deal with these exceptions, as these exceptions will leave your
application in an unknown state. Where possible, exceptions should be
handled by a structured exception handling block.
--
Greetz,
Jan
__________________________________
Read my weblog: http://weblogs.asp.net/jan
"Ori" <or*******@hotmail.com> schreef in bericht
news:b4*************************@posting.google.co m... Hi,
I would like to create some mechanism to handle all the exceptions which will happen in my application.
I have one form which is the base form while all the other forms inherit from it.
I try to find a way to "register" the base form to the Error handling , but I don't know how..
Basically I'm try to catch an exceptions which occur in form2 (which inherit from form1) through and exception handling which I will implement through form1.
If any one has any idea, please let me know.
Thanks,
Ori.
Hello Jay, For console applications look at: System.AppDomain.UnhandledException event Use AddHandler in your Sub Main.
Is this event only for console applications? I thought it is raised despite
the type of the application (well, ASP .NET ones can be an exception). The
docs seem to say nothing about WinForms or console applications in the
"AppDomain.UnhandledException" topic.
--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE
"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl... Ori, Depending on the type of application you are creating, .NET has three different global exception handlers.
For ASP.NET look at: System.Web.HttpApplication.Error event Normally placed in your Global.asax file.
For console applications look at: System.AppDomain.UnhandledException event Use AddHandler in your Sub Main.
For Windows Forms look at: System.Windows.Forms.Application.ThreadException event Use AddHandler in your Sub Main.
Hope this helps Jay
"Ori" <or*******@hotmail.com> wrote in message news:b4*************************@posting.google.co m... Hi,
I would like to create some mechanism to handle all the exceptions which will happen in my application.
I have one form which is the base form while all the other forms inherit from it.
I try to find a way to "register" the base form to the Error handling , but I don't know how..
Basically I'm try to catch an exceptions which occur in form2 (which inherit from form1) through and exception handling which I will implement through form1.
If any one has any idea, please let me know.
Thanks,
Ori.
Dmitriy,
Yes its raised on all three, however it is the only one raised for console
applications, the other two are not.
My understanding of the event itself, which I admit is limited, its
usefulness in ASP.NET & Windows Form is "limited", hence my statement "for
console application". As I personally do not have a clear indication of when
you would need to include it in ASP.NET & Windows Forms, at least I cannot
really explain it. If you have something the clearly & briefly explains when
the event is raised, I would love to hear it.
Remember most unhandled exceptions in most Windows Forms apps will be
handled by the Application.ThreadException, the AppDomain.UnhandledException
will only handle the exceptions not handled by the above handler... (at
least that is my experience).
Hope this helps
Jay
"Dmitriy Lapshin [C# / .NET MVP]" <x-****@no-spam-please.hotpop.com> wrote
in message news:O9**************@TK2MSFTNGP11.phx.gbl... Hello Jay,
For console applications look at: System.AppDomain.UnhandledException event Use AddHandler in your Sub Main. Is this event only for console applications? I thought it is raised
despite the type of the application (well, ASP .NET ones can be an exception). The docs seem to say nothing about WinForms or console applications in the "AppDomain.UnhandledException" topic.
-- Dmitriy Lapshin [C# / .NET MVP] X-Unity Test Studio http://x-unity.miik.com.ua/teststudio.aspx Bring the power of unit testing to VS .NET IDE
"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in message news:%2****************@TK2MSFTNGP10.phx.gbl... Ori, Depending on the type of application you are creating, .NET has three different global exception handlers.
For ASP.NET look at: System.Web.HttpApplication.Error event Normally placed in your Global.asax file.
For console applications look at: System.AppDomain.UnhandledException event Use AddHandler in your Sub Main.
For Windows Forms look at: System.Windows.Forms.Application.ThreadException event Use AddHandler in your Sub Main.
Hope this helps Jay
"Ori" <or*******@hotmail.com> wrote in message news:b4*************************@posting.google.co m... Hi,
I would like to create some mechanism to handle all the exceptions which will happen in my application.
I have one form which is the base form while all the other forms inherit from it.
I try to find a way to "register" the base form to the Error handling , but I don't know how..
Basically I'm try to catch an exceptions which occur in form2 (which inherit from form1) through and exception handling which I will implement through form1.
If any one has any idea, please let me know.
Thanks,
Ori.
> Remember most unhandled exceptions in most Windows Forms apps will be handled by the Application.ThreadException, the
AppDomain.UnhandledException will only handle the exceptions not handled by the above handler... (at least that is my experience).
Yes, I have bumped into something similar when working on a VS .NET add-in.
Strangely enough, the UnhandledException event didn't raise for the primary
thread the add-in was running on, while the event was raised as expected for
any other thread I had created manually. This came as a big and unpleasant
surprise, and I still haven't got any 'official' explanation. My only guess
is since VS .NET communicates with the add-in through CCW (COM-callable
wrappers), it is possible the framework silently installs its own handler
for the UnhandledException event to translate a managed exception to a COM
error (HRESULT + IErrorInfo).
As for the WinForms and ASP .NET applications, it is indeed better to use
the recommended means such as Application.ThreadException. Still, I'd add a
handler for UnhandledException too not to miss "survivors" who managed to
bypass the "first line of defense".
--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE
"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl... Dmitriy, Yes its raised on all three, however it is the only one raised for console applications, the other two are not.
My understanding of the event itself, which I admit is limited, its usefulness in ASP.NET & Windows Form is "limited", hence my statement "for console application". As I personally do not have a clear indication of
when you would need to include it in ASP.NET & Windows Forms, at least I cannot really explain it. If you have something the clearly & briefly explains
when the event is raised, I would love to hear it.
Remember most unhandled exceptions in most Windows Forms apps will be handled by the Application.ThreadException, the
AppDomain.UnhandledException will only handle the exceptions not handled by the above handler... (at least that is my experience).
Hope this helps Jay
Dmitriy, Still, I'd add a handler for UnhandledException too not to miss "survivors" who managed to bypass the "first line of defense".
You won't get an argument for me, I was attempting the highlight just the
first line of defense, in an effort to "keep it simple".
When I use my exception snippet again I will try to incorporate our
discussion...
Thanks
Jay
"Dmitriy Lapshin [C# / .NET MVP]" <x-****@no-spam-please.hotpop.com> wrote
in message news:eS**************@TK2MSFTNGP11.phx.gbl... Remember most unhandled exceptions in most Windows Forms apps will be handled by the Application.ThreadException, the AppDomain.UnhandledException will only handle the exceptions not handled by the above handler... (at least that is my experience).
Yes, I have bumped into something similar when working on a VS .NET
add-in. Strangely enough, the UnhandledException event didn't raise for the
primary thread the add-in was running on, while the event was raised as expected
for any other thread I had created manually. This came as a big and unpleasant surprise, and I still haven't got any 'official' explanation. My only
guess is since VS .NET communicates with the add-in through CCW (COM-callable wrappers), it is possible the framework silently installs its own handler for the UnhandledException event to translate a managed exception to a COM error (HRESULT + IErrorInfo).
As for the WinForms and ASP .NET applications, it is indeed better to use the recommended means such as Application.ThreadException. Still, I'd add
a handler for UnhandledException too not to miss "survivors" who managed to bypass the "first line of defense".
-- Dmitriy Lapshin [C# / .NET MVP] X-Unity Test Studio http://x-unity.miik.com.ua/teststudio.aspx Bring the power of unit testing to VS .NET IDE
"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in message news:%2****************@TK2MSFTNGP12.phx.gbl... Dmitriy, Yes its raised on all three, however it is the only one raised for
console applications, the other two are not.
My understanding of the event itself, which I admit is limited, its usefulness in ASP.NET & Windows Form is "limited", hence my statement
"for console application". As I personally do not have a clear indication of when you would need to include it in ASP.NET & Windows Forms, at least I
cannot really explain it. If you have something the clearly & briefly explains when the event is raised, I would love to hear it.
Remember most unhandled exceptions in most Windows Forms apps will be handled by the Application.ThreadException, the AppDomain.UnhandledException will only handle the exceptions not handled by the above handler... (at least that is my experience).
Hope this helps Jay
Jay,
I didn't mean to argue either, my sole intention was to warn you and the
community that peculiar things with UnhandledException could happen and they
were undocumented.
--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE
"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in message
news:uU**************@tk2msftngp13.phx.gbl... Dmitriy, Still, I'd add a handler for UnhandledException too not to miss "survivors" who managed
to bypass the "first line of defense". You won't get an argument for me, I was attempting the highlight just the first line of defense, in an effort to "keep it simple".
When I use my exception snippet again I will try to incorporate our discussion...
Thanks Jay
"Dmitriy Lapshin [C# / .NET MVP]" <x-****@no-spam-please.hotpop.com> wrote in message news:eS**************@TK2MSFTNGP11.phx.gbl... Remember most unhandled exceptions in most Windows Forms apps will be handled by the Application.ThreadException, the AppDomain.UnhandledException will only handle the exceptions not handled by the above handler...
(at least that is my experience).
Yes, I have bumped into something similar when working on a VS .NET
add-in. Strangely enough, the UnhandledException event didn't raise for the primary thread the add-in was running on, while the event was raised as expected for any other thread I had created manually. This came as a big and
unpleasant surprise, and I still haven't got any 'official' explanation. My only guess is since VS .NET communicates with the add-in through CCW (COM-callable wrappers), it is possible the framework silently installs its own
handler for the UnhandledException event to translate a managed exception to a
COM error (HRESULT + IErrorInfo).
As for the WinForms and ASP .NET applications, it is indeed better to
use the recommended means such as Application.ThreadException. Still, I'd
add a handler for UnhandledException too not to miss "survivors" who managed
to bypass the "first line of defense".
-- Dmitriy Lapshin [C# / .NET MVP] X-Unity Test Studio http://x-unity.miik.com.ua/teststudio.aspx Bring the power of unit testing to VS .NET IDE
"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in
message news:%2****************@TK2MSFTNGP12.phx.gbl... Dmitriy, Yes its raised on all three, however it is the only one raised for console applications, the other two are not.
My understanding of the event itself, which I admit is limited, its usefulness in ASP.NET & Windows Form is "limited", hence my statement "for console application". As I personally do not have a clear indication
of when you would need to include it in ASP.NET & Windows Forms, at least I cannot really explain it. If you have something the clearly & briefly
explains when the event is raised, I would love to hear it.
Remember most unhandled exceptions in most Windows Forms apps will be handled by the Application.ThreadException, the AppDomain.UnhandledException will only handle the exceptions not handled by the above handler...
(at least that is my experience).
Hope this helps Jay
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Daniel Wilson |
last post by:
I am having exception-handling and stability problems with .NET. I will
have a block of managed code inside try...catch and will still get a generic
..NET exception box that will tell me which...
|
by: Noor |
last post by:
please tell the technique of centralize exception handling without try catch
blocks in c#.
|
by: Master of C++ |
last post by:
Hi,
I am an absolute newbie to Exception Handling, and I am trying to
retrofit exception handling to a LOT of C++ code that I've written
earlier. I am just looking for a bare-bones, low-tech...
|
by: C# Learner |
last post by:
Some time ago, I remember reading a discussion about the strengths and
weaknesses of exception handling. One of the weaknesses that was put
forward was that exception handling is inefficient (in...
|
by: Ele |
last post by:
When Exception handling disabled compiler still spits out "C++ exception
handler used." Why is that?
Why does it ask for "Specify /EHsc"?
Thanks!
c:\Program Files\Microsoft Visual Studio...
|
by: Jon |
last post by:
Can someone point me to a best practices for exception handling in .Net 2?
We have a method that we like for ASP.Net apps on .Net 1.1, but are just
moving to 2.0 with winforms apps.
Is it still...
|
by: Robin Riley |
last post by:
Hi,
I have a .NET solution that contains a dll project and a tester application
project which, of course, invokes the dll. The dll project has exception
handling in it. What's happening is that...
|
by: Zytan |
last post by:
Ok something simple like int.Parse(string) can throw these exceptions:
ArgumentNullException, FormatException, OverflowException
I don't want my program to just crash on an exception, so I must...
|
by: George2 |
last post by:
Hello everyone,
Such code segment is used to check whether function call or exception-
handling mechanism runs out of memory first (written by Bjarne),
void perverted()
{
try{
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
| |