问题描述
这是我的一小段代码.
protected void ViewVisio(string url)
{
// open document
Microsoft.Office.Interop.Visio.Application visApp =
new Microsoft.Office.Interop.Visio.Application();
Microsoft.Office.Interop.Visio.Document visDoc = // application hangs here
visApp.Documents.Open(url);
...
}
基本上,应用程序只是永远挂在打开文档的那一行上.它永远不会超时,即使在几个小时之后,它也永远不会抛出异常.我检查了 Windows 事件日志,什么都没有.
Basically, the application just hangs forever on the line that opens the document. It never times out, even after a few hours, and it never throws an exception. I checked the Windows event logs, and there's nothing there.
我在我的服务器上安装了具有所有正确权限的 Office.我正在对 Word、Excel 和 PowerPoint 文件做同样的事情,而且它们都运行良好,所以我认为这与此无关.
I have Office installed on my server with all the correct permissions. I'm doing the same thing with Word, Excel, and PowerPoint files and they all work just fine, so I don't think it has anything to do with that.
所以我在这里有点不知所措-有人知道可能是什么问题吗?
So I'm at a bit of a loss here - anyone know what the issue could be?
推荐答案
切勿在自动化上下文中运行 Microsoft Office.Microsoft 不推荐或支持此操作(请参阅 KB257757 此处).
Never run Microsoft Office under an automation context. Microsoft does not recommend or support this (see KB257757 here).
Microsoft 目前不建议也不支持从任何无人参与的非交互式客户端应用程序或组件(包括 ASP、ASP.NET、DCOM 和 NT 服务)自动化 Microsoft Office 应用程序,因为 Office 可能表现出不稳定在此环境中运行 Office 时的行为和/或死锁.
这篇关于打开 Visio 文档时应用程序永远挂起的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!