Catch an exception in DLL...?  
Author Message
IamHuM





PostPosted: Visual C# General, Catch an exception in DLL...? Top

Hi...

I want to catch an exception in opening Serial Port.

I have a line in my DLL code as -

SerialPort.Open();

For this line i want to catch a exception using try...catch() & i want to pop up a dialog box (MessageBox)...Thisline is in DLL so how i can pop up a MesageBox from a DLL is it Possible...

Thanks,

Vinay



Visual C#18  
 
 
Mattias Sjogren





PostPosted: Visual C# General, Catch an exception in DLL...? Top

Yes it's totally possible (just reference System.Windows.Forms.dll). Whether it's a good thing for a class library to report errors using message boxes is another question. I wouldn't recommend doing it. Let the UI application handle reporting errors to the user instead.