Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/visual-studio-2010/4.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/blackberry/2.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# Excel互操作-类型未注册_C#_Visual Studio 2010_Excel_Interop - Fatal编程技术网

C# Excel互操作-类型未注册

C# Excel互操作-类型未注册,c#,visual-studio-2010,excel,interop,C#,Visual Studio 2010,Excel,Interop,我有一个为x86平台编译的C#winform应用程序,使用excel 2003 COM互操作库。Visual studio项目引用了以下用于office 2003的互操作文件 Microsoft.Office.Interop.Excel.dll(v 11.0.0,特定版本=true) Microsoft.Vbe.Interop.dll(v 11.0.0,特定版本=false) 此应用程序在大多数使用excel 20032007和2010的计算机上运行良好,但其中一个用户向我报告了以下异常 此用户

我有一个为x86平台编译的C#winform应用程序,使用excel 2003 COM互操作库。Visual studio项目引用了以下用于office 2003的互操作文件

Microsoft.Office.Interop.Excel.dll(v 11.0.0,特定版本=true) Microsoft.Vbe.Interop.dll(v 11.0.0,特定版本=false)

此应用程序在大多数使用excel 20032007和2010的计算机上运行良好,但其中一个用户向我报告了以下异常

此用户具有windows 7和Office 2010

System.InvalidCastException: Unable to cast COM object of type 'Microsoft.Office.Interop.Excel.ApplicationClass' to interface type 'Microsoft.Office.Interop.Excel._Application'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{000208D5-0000-0000-C000-000000000046}' failed due to the following error: Library not registered. (Exception from HRESULT: 0x8002801D (TYPE_E_LIBNOTREGISTERED)).

   at Microsoft.Office.Interop.Excel.ApplicationClass.get_Workbooks()
从我所读到的内容来看,这个问题可能发生在Office版本冲突的情况下,但由于我特别引用了2003 Office PIA并将其与应用程序一起分发,我不确定是什么导致了这个问题


谢谢

用户的注册表已损坏。他已安装Office,否则您将永远无法创建应用程序对象,但Typelib注册表项中缺少一个条目。需要允许互操作调用成功


重新安装Office是明智而简单的解决方案。这种损失很少是孤立的。

您看到了吗?是的,我看到了,但在我的场景中,我正确地引用了客户机应该使用的PIA(v11,Excel 2003),这是一个您可以使用的选项?这样,您就不必担心目标pc的版本。可能的副本。您在这里有一个很好的解决方案。@Siddharth:修改所有代码需要一段时间,因此我更愿意修复注册表如果我可以要求用户进行修复,我们将看看如何进行