2014-02-11 73 views
0

我在另一個項目中添加了一個現有的表單(及其引用),我試圖顯示新的表單。有沒有編碼的問題,只是一個參考錯誤:程序集引用丟失指令

The type or namespace 'frmEmail' could not be found (are you missing a using directive or an assembly reference?)

我無法弄清楚什麼是「使用」或參考我沒有導入其他形式時使用。有任何想法嗎?

這裏是代碼導致錯誤:

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(); 
    } 
} 
} 
+1

如果您不向我們顯示您的代碼,您認爲我們可以提供什麼幫助? –

+0

打開窗體的源代碼,導航到頂部,並查看VS顯示的智能感知錯誤。 –

+0

轉到爲frmEmail(文件頂部)定義名稱空間的位置。它可能是你原來的代碼的命名空間。將其更改爲新的代碼命名空間 – dreza

回答

1

你需要拉的命名空間中。例如,如果這是你的形式目前是如何在其他項目:

namespace Your.Form.Namespace { // this is important 
    public class YourForm : Form { 
     // stuff 
    } 
} 

然後在項目中添加它..您需要添加您的程序集作爲參考,然後像這樣導入命名空間:

using Your.Form.Namespace; // import the namespace 

namespace Other.Project { 
    public class OtherClass { 
     YourForm _form; // this is fine now 
    } 
} 

其他選項是完全限定類型。這意味着在聲明中使用整個名稱空間和類型名稱。這將是這樣的:

namespace Other.Project { 
    public class OtherClass { 
     Your.Form.Namespace.YourForm _form; // this is fine too 
    } 
} 
0

I added an existing form (and it's references) to another project and I am trying to show the new form.

看起來你添加的形式是frmNotifications,但創造的frmEmail一個實例。你還加了嗎?

相關問題