简体   繁体   English

Word自动化服务器端无法正常工作

[英]Word automation server-side not working

PREFACE: Yes, I know that Microsoft does not recommend this. 前言:是的,我知道微软不推荐这个。 However, this server is internal-facing in a heavily restricted VLAN. 但是,此服务器在严格受限的VLAN中面向内部。

The goal is to automatically generate specific types of reports that I could not get formatted properly using the Office XML. 目标是自动生成特定类型的报告,使用Office XML无法正确格式化。 One of the reasons Microsoft does not recommend this is that the user account must be interactive (ie NOT ASPNET). Microsoft建议不要这样做的原因之一是用户帐户必须是交互式的(即不是ASPNET)。 So if I set the application pool identity to run as a user, I no longer get COM errors, but Word still will not open using the following test code: 因此,如果我将应用程序池标识设置为以用户身份运行,则不会再出现COM错误,但仍无法使用以下测试代码打开Word:

//Just checking if Word can be accessed
Word.Application app = new Word.Application();
app.Visible = true;

I do not get any errors, but Word will not open. 我没有收到任何错误,但Word不会打开。 This works when I use it on my development machine debugging with Visual Studio, but on my test machine when deployed I get nothing. 当我在使用Visual Studio进行开发机器调试时使用它时,这种方法有效,但在部署时,我的测试机器上没有任何内容。 Any tips would be greatly appreciated. 任何提示将非常感谢。

Even if the application pool is running under user account, it does not mean that it is interactive and can access your desktop. 即使应用程序池在用户帐户下运行,也不意味着它是交互式的并且可以访问您的桌面。 You can check the list of running processes to find out if Word is there. 您可以检查正在运行的进程列表,以确定Word是否存在。

As you already know: Office Interop/Automation is NOT supported by MS in "server-like scenarios" (which IIS/ASP.NET is a special kind of)... see KB257757 如您所知:MS在“类似服务器的场景”(IIS / ASP.NET是一种特殊的场景)中不支持Office Interop / Automation ...参见KB257757

Your options include several libtraries (free and commercial) - for example: 您的选择包括几个图书馆(免费和商业) - 例如:

Since Windows Vista several changes have been introduced to stop any Windows Service (IIS is just some special one) from doing anything "desktop-like" - this is due to security issues... to resolve such a situation you would need to circumvent those security measures implemented by MS - which I absolutely do NOT recommend... 自Windows Vista以来,已经引入了一些更改来阻止任何Windows服务(IIS只是一些特殊的服务)做任何“桌面式” - 这是由于安全问题...要解决这种情况,你需要绕过这些MS实施的安全措施 - 我绝对不建议......

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM