组装参考缺少指令 [英] Missing directive of assembly reference
问题描述
我添加了现有的形式(和它的引用)到另一个项目,我试图以显示新的形式。有没有编码的问题,只是一个参考错误:
I added an existing form (and it's references) to another project and I am trying to show the new form. There are no coding issues, just a reference error:
类型或命名空间frmEmail'找不到(是否缺少
按指令或程序集引用?)
The type or namespace 'frmEmail' could not be found (are you missing a using directive or an assembly reference?)
我无法弄清楚什么是使用或参考导入时我没有使用的其他形式。 ?任何想法
I cannot figure out what "using" or reference I failed to use when importing the other form. Any ideas?
下面是调用错误的代码:
Here is the code calling the error:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace Notify_Setup
{
public partial class frmNotifications : Form
{
public frmNotifications()
{
InitializeComponent();
pbBlue.MouseEnter += new EventHandler(pbBlue_MouseEnter);
}
private void pbGreen_Click(object sender, EventArgs e)
{
frmEmail frmEmail = new frmEmail();
frmEmail.Show();
this.Hide();
}
}
}
}
推荐答案
您需要拉命名空间。例如,如果这是你的表目前是如何在其他项目:
You need to pull the namespace in. For example, if this was how your form currently was in the other project:
namespace Your.Form.Namespace { // this is important
public class YourForm : Form {
// stuff
}
}
然后在项目中您要添加到..你需要添加组件,引用,然后导入命名空间中是这样的:
Then in the project you're adding it to.. you need to add your assembly as a reference, then import the namespace in like this:
using Your.Form.Namespace; // import the namespace
namespace Other.Project {
public class OtherClass {
YourForm _form; // this is fine now
}
}
其他的选项就是完全限定的类型。这意味着什么,是在声明中使用整个空间和类型名称。这将是这样的:
The other options is to fully qualify the type. What this means, is to use the entire namespace and type name in the declaration. It would be like this:
namespace Other.Project {
public class OtherClass {
Your.Form.Namespace.YourForm _form; // this is fine too
}
}
这篇关于组装参考缺少指令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!