从类库引用System.Windows.Forms [英] Referencing System.Windows.Forms from a Class Library

查看:79
本文介绍了从类库引用System.Windows.Forms的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个类库,需要从PictureBox继承:公共类Picture:PictureBox {...} ,但是当我尝试添加时 Forms 不可用在我的类库顶部的using指令: using System.Windows.Forms; .我知道我可以通过右键单击解决方案资源管理器"中的引用"并选择添加引用",然后从列表中添加System.Windows.Forms程序集来使其正常工作.

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.

但是可以这样做吗?从类库中引用WindowsForms 可以吗?

But is it okay to do this? Is it okay to reference WindowsForms from a Class Library?

推荐答案

完全可以做到这一点.

System.Windows.Forms 只是一个与任何其他程序集一样的程序集.对项目文件没有特殊处理,例如Office加载项.

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.

这篇关于从类库引用System.Windows.Forms的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆