简体   繁体   中英

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.

The goal is to automatically generate specific types of reports that I could not get formatted properly using the Office XML. One of the reasons Microsoft does not recommend this is that the user account must be interactive (ie NOT 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:

//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. This works when I use it on my development machine debugging with Visual Studio, but on my test machine when deployed I get nothing. 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.

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

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...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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