Click here to Skip to main content
15,909,503 members
Home / Discussions / C#
   

C#

 
QuestionHow to catch a exception from another class? Pin
softwarejaeger30-Dec-08 4:13
softwarejaeger30-Dec-08 4:13 
AnswerRe: How to catch a exception from another class? Pin
Christian Graus30-Dec-08 4:25
protectorChristian Graus30-Dec-08 4:25 
GeneralRe: How to catch a exception from another class? Pin
softwarejaeger30-Dec-08 4:31
softwarejaeger30-Dec-08 4:31 
AnswerRe: How to catch a exception from another class? Pin
karoitay30-Dec-08 4:29
karoitay30-Dec-08 4:29 
AnswerRe: How to catch a exception from another class? Pin
PIEBALDconsult30-Dec-08 4:43
mvePIEBALDconsult30-Dec-08 4:43 
AnswerRe: How to catch a exception from another class? Pin
Wendelius30-Dec-08 5:35
mentorWendelius30-Dec-08 5:35 
AnswerRe: How to catch a exception from another class? Pin
#realJSOP30-Dec-08 6:58
professional#realJSOP30-Dec-08 6:58 
AnswerRe: How to catch a exception from another class? Pin
Daniel Grunwald30-Dec-08 8:51
Daniel Grunwald30-Dec-08 8:51 
It depends on where the exception is thrown.
If the class throws an exception during a call from the application, simply wrap the call in a try-catch to catch the exception.
If the class displays UI and throws an exception in a click event handler/timer/etc., use the Application.ThreadException event to handle the exception.
If the class creates a new thread and throws an exception there, you can display an error dialog from AppDomain.CurrentDomain.UnhandledException, but the AppDomain will usually terminate after the error. You'll have to host the class in a separate AppDomain to let your main program survive those cases.
That still won't help if the class calls into unmanaged code and crashes there - the process will terminate. You would have to host addins in a separate process to prevent that.

In my opinion, simply handling exceptions in the most common cases should suffice, but if you want more isolation, you should take a look at System.AddIns[^].
QuestionEvent registration Pin
karoitay30-Dec-08 2:59
karoitay30-Dec-08 2:59 
AnswerRe: Event registration Pin
N a v a n e e t h30-Dec-08 3:31
N a v a n e e t h30-Dec-08 3:31 
GeneralThanks Pin
karoitay30-Dec-08 4:17
karoitay30-Dec-08 4:17 
QuestionExcel Tables Pin
twsted f830-Dec-08 2:58
twsted f830-Dec-08 2:58 
AnswerRe: Excel Tables Pin
EricGoodchild30-Dec-08 15:07
EricGoodchild30-Dec-08 15:07 
QuestionObject reference not set to an instance of an object? Pin
dec8230-Dec-08 1:53
dec8230-Dec-08 1:53 
AnswerRe: Object reference not set to an instance of an object? [modified] Pin
Xmen Real 30-Dec-08 1:59
professional Xmen Real 30-Dec-08 1:59 
GeneralRe: Object reference not set to an instance of an object? Pin
dec8230-Dec-08 2:11
dec8230-Dec-08 2:11 
GeneralRe: Object reference not set to an instance of an object? Pin
Xmen Real 30-Dec-08 2:20
professional Xmen Real 30-Dec-08 2:20 
GeneralRe: Object reference not set to an instance of an object? Pin
dec8230-Dec-08 2:36
dec8230-Dec-08 2:36 
GeneralRe: Object reference not set to an instance of an object? Pin
Xmen Real 30-Dec-08 2:40
professional Xmen Real 30-Dec-08 2:40 
AnswerRe: Object reference not set to an instance of an object? Pin
Member 428013630-Dec-08 2:03
Member 428013630-Dec-08 2:03 
AnswerRe: Object reference not set to an instance of an object? Pin
Brij30-Dec-08 2:04
mentorBrij30-Dec-08 2:04 
AnswerRe: Object reference not set to an instance of an object? Pin
Member 428013630-Dec-08 2:09
Member 428013630-Dec-08 2:09 
Questionhow can i import another projects/language .exe file into my project to run in C# Pin
D V kirankumar30-Dec-08 1:48
D V kirankumar30-Dec-08 1:48 
AnswerRe: how can i import another projects/language .exe file into my project to run in C# Pin
Christian Graus30-Dec-08 4:26
protectorChristian Graus30-Dec-08 4:26 
GeneralRe: how can i import another projects/language .exe file into my project to run in C# Pin
D V kirankumar30-Dec-08 23:00
D V kirankumar30-Dec-08 23:00 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.