C#调用excel提示com出错的解决方案

错误信息:000208D5-0000-0000-C000-000000000046

Unable to cast COM object of type 'System.__ComObject' 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: 程式庫未登錄。 (Exception from HRESULT: 0x8002801D (TYPE_E_LIBNOTREGISTERED)).

重装office,修复office,对此可能无效。

最终解决办法,在注册表中找到如下注册项

HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Classes\TypeLib\{00020813-0000-0000-C000-000000000046}

reg delete HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Classes\TypeLib\{00020813-0000-0000-C000-000000000046}\1.9

我电脑上装的是office 2007,也就是1.6版本的库,然而下面还有个1.9的,程序好像默认按照高版本的先识别,也就是优先识别1.9的,

但是我的电脑并未装1.9 的office,于是删除掉1.9的这一项,试了一下,问题解决。

或者把1.9改为1.6以下的,同样可解决问题。其他版本以此类推

 

 

 

posted @ 2017-12-22 14:40  Jesse!  阅读(3181)  评论(0)    收藏  举报