c# - Word Document.Close 和线程中止异常 Windows 7

标签 c# .net ms-word vsto ms-office

我有一个项目类型的 office 2010 word 文档。

在功能区中有一个按钮可以执行一些逻辑。 在这个逻辑的末尾有一行:

Globals.ThisDocument.Application.ActiveDocument.Close(ref dowdSaveChanges, ref oMissing, ref oMissing);

在 Windows XP 上一切正常,但是当用户尝试在 Windows 7 上使用此文档时,这行代码会抛出如下异常:

System.Threading.ThreadAbortException: The thread was beeing aborted. 
   w Document35.WorkflowRibbon.Button1Click(Object sender, RibbonControlEventArgs e) w D:\_DEV\WorkflowCS2_WordTemplatest_Office2010\Document35\WorkflowRibbon.cs:wiersz

可能是什么原因?

最佳答案

这似乎是 AppDomain 卸载并将执行从非托管代码返回到托管代码的问题。 See MSDN forums其中讨论了此 ThreadAbortExcpetion 行为。可能您只需要更新 VSTO 运行时。

关于c# - Word Document.Close 和线程中止异常 Windows 7,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9195572/

相关文章:

.net - .NET 错误处理工具

.net - 如何在通用 Windows 平台应用程序中更新一个特定的 dotnet 程序集?

vba - 填写表格ms-word VBA/通过Word进行最有效的智能导航

c# - Masstransit 使用RabbitMQ 性能很慢?

c# - PDF表: last cell is not visible

.net - ASP.NET MVC-强制为Razor(cshtml)文件提供自定义基类

ms-word - Word VSTO在运行时吞没了异常而无需调试?

c# - C# 中锁定(或进入/退出)的最佳实践

c# - 单击按钮获取选定行

web-applications - 打开远程文档并保存回远程服务器