Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/305.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# Windows应用程序中的System.Runtime.InteropServices.COMException_C#_Forms_Exception - Fatal编程技术网

C# Windows应用程序中的System.Runtime.InteropServices.COMException

C# Windows应用程序中的System.Runtime.InteropServices.COMException,c#,forms,exception,C#,Forms,Exception,我在Visual Studio 2012中开发了一个Windows应用程序,目标框架为.NET 4。我在WindowsXPSP2机器上部署了它。它过去工作正常,但现在Windows XP被重新安装,应用程序无法工作。我已在XP中安装了.NET 4 framework,但它显示以下错误(来自事件查看器): 我在谷歌上搜索解决方案,我认为异常意味着“当从COM方法调用返回无法识别的HRESULT时引发的异常”。但这没有帮助。有人知道是什么导致了这个错误吗 Program.Main(): 尝试调试导致

我在Visual Studio 2012中开发了一个Windows应用程序,目标框架为.NET 4。我在WindowsXPSP2机器上部署了它。它过去工作正常,但现在Windows XP被重新安装,应用程序无法工作。我已在XP中安装了.NET 4 framework,但它显示以下错误(来自事件查看器):

我在谷歌上搜索解决方案,我认为异常意味着“当从COM方法调用返回无法识别的HRESULT时引发的异常”。但这没有帮助。有人知道是什么导致了这个错误吗

Program.Main():


尝试调试导致此错误的原因。 尝试在引发异常时中断

步骤:- 转到调试>异常。。。并使用查找。。。用于定位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")
希望这有帮助

问候


M

谢谢Raghu,但它在VisualStudio和Windows7中运行良好。在调试模式下不会引发异常。只有在Windows XP中打开exe时才会出现问题。您有任何代码吗?在出现错误的地方添加了一些代码。请尝试从该窗体中删除控件,直到找到哪个控件是问题制造者
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());
        }
    }
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());
            }
        }
1.Try running visual studio or application as "Run as administrator".
2.Check which platform did you set during build ("AnyCPU, x86, x64")