Your program does not work locally in debug mode. You just did not use any errors.
You should never , under any circumstances, use any of the Office Automation APIs from an ASP.NET application or any other server application. These APIs are designed to appeal to an interactive desktop application. Many of the assumptions they make do not apply to server applications.
For example, a desktop application synchronizes when user actions become messages in the Windows message queue. ASP.NET does not have a Windows message queue, so access to shared data is not synchronized. Your tests may simply never cause multiple threads to run simultaneously.
There may be data that exists in only one copy for all users of this COM component. This works great in a desktop application as there is only one user. Your ASP.NET application has many users who execute code at the same time. Another assumption is violated.
All these things will create subtle mistakes that really cannot be fixed. They can only be moved, leaving you to think that you have solved the problem, up to the moment when you understand that there is another problem. This cycle never ends and never can end, because you will not solve the actual problem: the problem was that you used the Office Automation API from the server application.
Fix this problem and you will no longer have such errors.
PS It also happens that you may violate your license for Microsoft Word, unless all users of your ASP.NET application have licenses for the Word application.
John saunders
source share