我在Visual Studio 2012中開發了一個Windows應用程序,目標框架爲.NET 4.我將它部署在Windows XP SP2計算機上。它曾經工作得很好,但現在Windows XP已重新安裝,應用程序無法正常工作。我已經安裝在XP的.NET框架4,但它顯示了以下錯誤(事件查看器):Windows應用程序中的System.Runtime.InteropServices.COMException
Application: SGate.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.Runtime.InteropServices.COMException
Stack:
at System.RuntimeTypeHandle.CreateInstance(System.RuntimeType, Boolean, Boolean, Boolean ByRef, System.RuntimeMethodHandleInternal ByRef, Boolean ByRef)
at System.RuntimeType.CreateInstanceSlow(Boolean, Boolean, Boolean)
at System.RuntimeType.CreateInstanceDefaultCtor(Boolean, Boolean, Boolean, Boolean)
at System.Activator.CreateInstance(System.Type, Boolean)
at SGate.Gate..ctor()
at SGate.Program.Main()
我用Google搜索的解決方案,我想通了異常的意思是「當一個無法識別的HRESULT是引發的異常從COM方法調用返回「。但是這並沒有幫助。有誰知道是什麼原因導致這個錯誤?
Program.Main():
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Gate());
}
}
門CTR()和相關功能:
public Gate()
{
InitializeComponent();
ClearForm();
}
private void ClearForm()
{
try
{
leaveApply = new EmployeeLeaveApplyBO();
CurrentPageIndex = 1;
dataGridView1.DataSource = null;
lblFromDate.Text = "";
lblLeaveReason.Text = "";
lblLeavType.Text = "";
lblName.Text = "";
lblEmpCode.Text = "";
lblThumbID.Text = "";
lblToDate.Text = "";
lblStatus.Text = "STATUS";
lblStatus.ForeColor = Color.Black;
groupBox3.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(224)))), ((int)(((byte)(224)))), ((int)(((byte)(224)))));
groupBox1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(224)))), ((int)(((byte)(224)))), ((int)(((byte)(224)))));
}
catch (Exception e)
{
LogUtil.LogError(e.ToString());
}
}
你有任何的代碼? –
添加了一些錯誤似乎發生的代碼。 –
嘗試從該窗體中刪除控件,直到找出哪一個是製造商 –