Word Document.Close 和线程中止异常 Windows 7
我有一个项目类型为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
可能是什么原因?
I have a project type office 2010 word document.
In ribbon there is a button which does some logic.
On the end of this logic there is a line like:
Globals.ThisDocument.Application.ActiveDocument.Close(ref dowdSaveChanges, ref oMissing, ref oMissing);
On Windows XP everything worked ok but when a user tries to work with this document on Windows 7 this line of code throws exception like:
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
What could be the reason?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这似乎是 AppDomain 卸载并将执行从非托管代码返回到托管代码的问题。 查看 MSDN 论坛 其中讨论了此
ThreadAbortExcpetion
行为。您可能只需要更新 VSTO 运行时。This seems to be an issue of the AppDomain unloading and returning execution from unmanaged to managed code. See MSDN forums which discusses this
ThreadAbortExcpetion
behavior. Potentially you just need to update the VSTO Runtime.试试这个:
try this: