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

相关问题