mercoledì 25 maggio 2011

Error when using Microsoft Office Word Interop from a webservice

When trying to run a webservice that needs to access the Word application you can get the following error: 

"Retrieving the COM class factory for component with CLSID {000209FF-0000-0000-C000-000000000046} failed due to the following error: 80070005."

Set the user identity to the AppPool containing the WebService to someting like Local System or Word will not run properly. You may also need to install the Microsoft Primary Interop Assemblies.

If the error persists, you need to enable the com access to the use. Run "dcomcnfg" and go to Component Services -> Computers -> My Computer -> DCOM Config.

At the end of the list you will find "{00020906-0000-0000-C000-000000000046}" right click on it and select properties, go to Security and in "Launch and Activation Permissions" set Customize -> Edit and set the permissions for the user identity used by the AppPool containing the WebService.