我在Visual Studio 2012中开发了一个Windows应用程序,其目标框架为.NET 4.我将其部署在Windows XP SP2计算机中。它曾经工作正常,但现在重新安装Windows XP,应用程序无法正常工作。我在XP中安装了.NET 4框架,但它显示以下错误(来自事件查看器):
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()
我搜索了解决方案,我认为异常意味着“从COM方法调用返回无法识别的HRESULT时引发的异常。”但这没有用。有谁知道导致这个错误的原因是什么?
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());
}
}
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());
}
}
答案 0 :(得分:0)
尝试调试导致此错误的原因。 抛出异常时尝试断开。
步骤: - 转到Debug&gt;例外...并使用Find ...选项查找System.Runtime.InteropServices.COMException。勾选选项以在抛出时中断,然后调试应用程序。
你应该能够找到问题所在。
如果您不确定究竟是什么导致
,您可以尝试这些1.Try running visual studio or application as "Run as administrator".
2.Check which platform did you set during build ("AnyCPU, x86, x64")
希望这有帮助,
亲切的问候
Raghu.M