I am creating a Class Library and need to inherit from PictureBox: public class Picture : PictureBox { ... }
but Forms
is not available when I try to add a using directive for it at the top of my Class Library: using System.Windows.Forms;
. I know that I can get it to work by right-clicking Referenced in Solution Explorer and selecting Add Reference, then adding the System.Windows.Forms assembly from the list.
But is it okay to do this? Is it okay to reference WindowsForms from a Class Library?
It is totally okay to do this.
System.Windows.Forms
is just an assembly like any others. There is no special treatment to the project file, as with for example Office add-ins.
You can safely add this assembly to your project file.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With