MessageBox.show from class library

Hello experts,

currently in the process of attempting to write a class library.  what I am wondering is whether it's bad practice to incorporate the "System.Windows.Forms" namespace so I can get a messagebox to show in the event that there is an error.

thanks

LVL 7
brdrokAsked:
Who is Participating?
 
tinchosCommented:
It all depends on the purpose of your library.

If your library handles the user interface then I wouldn't consider it too wrong.

If it is a low level service class library, I would rather throw an exception or return an error code which would be processed in my app and depending on the returned value I would show a message box.

Hope this helps
Tincho

0
 
Razzie_Commented:
I don't see any reason why you would want to use a messagebox in a library. A library can *never* run as a standalone application. So there'd be no point in using a messagebox. I'd really return an error code or throw an exception and let the encapsulating application handle any possible UI components.

Cheers,

Razzie
0
 
brdrokAuthor Commented:
Heya,  

based on those two answers, I guess I'll stay away from messageBoxes.  Figured as much, but better to measure twice and cut once :)

0
 
brdrokAuthor Commented:
Forgot to mention, if you two know anything about sound C# designs and database designs, I will post a new question in a few minutes.  

thanks

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.