[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 389
  • Last Modified:

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

0
brdrok
Asked:
brdrok
  • 2
2 Solutions
 
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

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now