0

I have a pretty nasty problem. I wrote an application which does a programmatic mail merge for a customer using the Office.word.interop (Microsoft.Office.Interop.Word.dll). Everything worked fine. Then the customer wanted the same functionality from within a website and everything went downhill. I included my code in a website and everything worked in debug mode but when I published it and ran under IIS I keep getting the error:

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

When I Googled this I kept getting advice to use component services to change the Security setting to include the IIS user. On my 2003 Server I gave pretty much every permission there is to pretty much everybody but got no results. On my Windows 7 box I can't even edit the security without 'taking control of the registry key'. Which does not even seem to be worth looking into.

Is there any hope?

John Saunders
  • 160,644
  • 26
  • 247
  • 397
Belmiris
  • 2,741
  • 3
  • 25
  • 29
  • Do *not* use Office Interop on a server. It's a bad idea. I've tried it, and gives you many headaches. Microsoft says [don't do it too](http://support.microsoft.com/kb/257757) if you don't believe me. Instead, find a good Word library. I tried [DocX](http://www.codeproject.com/Articles/660478/Csharp-Create-and-Manipulate-Word-Documents-Progra) and it worked okay. – mason Apr 22 '14 at 20:56
  • It is a horrible idea to use Office Interop from ASP.NET or another server technology. These APIs were written for use in a desktop application, for automating Office (a suite of desktop applications). Server applications are different in many ways that make it a very, very bad idea to use Office Interop in them. It's also unsupported by Microsoft, and may violate your Office license. See [Considerations for server-side Automation of Office](http://support.microsoft.com/kb/257757) – John Saunders Apr 22 '14 at 20:57
  • Your only hope is to stop using Office Interop in a server application. If you continue on this path, you are doomed. – John Saunders Apr 22 '14 at 21:02

1 Answers1

0

I dont believe Office is thread safe (or even licensed) for use on a web server - even if you got it to work for a single user at a time, I doubt you would get trouble-free operation once you scaled it to multiple concurrent users.

Check your EULA on your Microsoft Office pack, you might find it is not licensed for this use (or this useage is specifically not supported). There are commercial .net libraries for server side document composition, and I recommend you use one of these purpose built ones rather than trying to do Office Interop (which in any case is very slow).

PhillipH
  • 6,182
  • 1
  • 15
  • 25