1

我在添加UserControl到表單時遇到問題。嘗試將UserControl添加到我的表單時出錯

用戶控件編碼:

using System; 
using System.Windows.Forms; 

namespace Most.Mobile.AFV.UI.Controls 
{ 
    public partial class ListActionBar : UserControl 
    { 
     public ListActionBar() 
     { 
      InitializeComponent(); 
     } 

     public bool ShowKeyboardButton 
     { 
      get { return mtbKeyboard.Visible; } 
      set { mtbKeyboard.Visible = value; } 
     } 

     public bool ShowOpenButton 
     { 
      get { return mtbMenu.Visible; } 
      set { mtbMenu.Visible = value; } 
     } 

     public bool ShowDeleteButton 
     { 
      get { return mtbDelete.Visible; } 
      set { mtbDelete.Visible = value; } 
     } 

     public bool ShowBackButton 
     { 
      get { return mtbBack.Visible; } 
      set { mtbBack.Visible = value; } 
     } 

     public bool ShowEditButton 
     { 
      get { return mtbEdit.Visible; } 
      set { mtbEdit.Visible = value; } 
     } 

     public bool ShowNewButton 
     { 
      get { return mtbNew.Visible; } 
      set { mtbNew.Visible = value; } 
     } 

     public event EventHandler NewClick; 
     public event EventHandler DeleteClick; 
     public event EventHandler EditClick; 
     public event EventHandler OpenClick; 

     private void mtbBack_Click(object sender, EventArgs e) 
     { 
      if (Parent == null) 
       return; 

      if (Parent is Form) 
       (Parent as Form).DialogResult = DialogResult.Cancel; 
     } 

     private void mtbKeyboard_Click(object sender, EventArgs e) 
     { 
      inp.Enabled = !inp.Enabled; 
     } 

     private void mtbNew_Click(object sender, EventArgs e) 
     { 
      if (NewClick != null) 
       NewClick(sender, e); 
     } 

     private void mtbEdit_Click(object sender, EventArgs e) 
     { 
      if (EditClick != null) 
       EditClick(sender, e); 
     } 

     private void mtbDelete_Click(object sender, EventArgs e) 
     { 
      if (DeleteClick != null) 
       DeleteClick(sender, e); 
     } 

     private void mtbMenu_Click(object sender, EventArgs e) 
     { 
      if (OpenClick != null) 
       OpenClick(sender, e); 
     } 
    } 
} 

下面對錯誤的圖象

Error image

錯誤說明:

無法創建部件 '' 「System.IO.FileLoadException:無法加載文件或程序集'Microsoft.WindowsCE.Forms,Version = 3.5.0.0,CUlture = neutral,PublicKeyToken = 9 69db8053d3322ac'或其依賴項之一。

回答

-1

在設計器視圖中顯示控件時,visual studio designer會實例化控件。當你得到這樣的錯誤時,通常意味着你有一個運行時錯誤。如果它編譯,請嘗試運行代碼(不要在設計器中打開它)並查看它在哪裏/是否崩潰。

+0

我忘了提及的另一個細節: 該項目在Windows Mobile 6.5上。 在我的機器上,這個錯誤不會發生。 錯誤只發生在我的同事的機器上 在運行模式下完美工作 – ridermansb 2011-03-25 13:33:25

相關問題