解决 interop.word 外部组件异常

未处理 System.Runtime.InteropServices.SEHException
  Message="外部组件发生异常。"
  Source="Interop.Word"
  ErrorCode=-2147467259
  StackTrace:
       在 Word.Find.set_Text(String prop)
       在 TPRI.Common.IOLibrary.OperatorWord.ReplaceText(String replaceText, String valueText) 位置 C:\Documents and Settings\lhb\My Documents\Reflector\Disassembler\TPRI.Common\TPRI\Common\IOLibrary\OperatorWord.cs:行号 108
       在 ConsoleApplication1.Program.Main(String[] args) 位置 C:\Documents and Settings\lhb\My Documents\Reflector\Disassembler\ConsoleApplication1\Program.cs:行号 17
       在 System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
       在 System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       在 Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       在 System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       在 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       在 System.Threading.ThreadHelper.ThreadStart()
  InnerException:

调用word组件产生以上错错误。
原因:word的注册的组件库损坏,需要重新注册word组件库
解决方法:
然后,在命令行中将 Regtlib.exe 与类型库的完整路径一起使用以向 COM 重新注册该库。Regtlib.exe 将在传入的类型库(.tlb 或 .olb)文件上调用 LoadTypeLib 和 RegisterTypeLib 应用程序接口 (API)。COM 会修复错误配置的注册表项。

Regtlib.exe "C:\Program Files\Microsoft Office\Office12\MSWORD.OLB"(注意:英文的双引号不是单引号),如果没有Regtlib.exe ,可以到C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\regtlibv12.exe 目录下执行
regtlibv12.exe  "C:\Program Files\Microsoft Office\Office12\MSWORD.OLB". regtlibv12.exe  为 Regtlib.exe升级版

转载于:https://www.cnblogs.com/hbb0b0/articles/1880490.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值