Retrieving the COM class factory for component err

2019-02-09 14:42发布

I am trying to edit a word document from VB.NET using for the most part this code:

How to automate Word from Visual Basic .NET to create a new document http://support.microsoft.com/kb/316383

It works fine on my machine but when i publish to the server i 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.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

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

The actual error happens when i try to just create a word application object

 Dim oWord As New Word.Application

Using Visual Studio 2008 and VB.NET 3.5. I made a reference to the "Microsoft Word 10.0 Object Library" and i see Interop.Word.dll file in the bin directory.

Using MS Office 2003 on development machine and Windows Server 2003

Still fairly new to .NET and don't have much knowledge about window server, but "UnauthorizedAccessException" sounds like a permission issue. I'm wondering if someone could point me in the right direction on what i might need to do to give my little application access to use word.

8条回答
劳资没心,怎么记你
2楼-- · 2019-02-09 15:30

I had the same problem while generating word document. The issue i solved by checking the task manager, and by ending the currently running process WINWORD.EXEs and then executed my code again. The issue gone.

查看更多
虎瘦雄心在
3楼-- · 2019-02-09 15:33

I was experiencing the same issue and the problem area I found was "security configuration for Microsoft Word in DCOM". On the following link you can find a step by step guide to know how to config components in DCOM, repeate these steps for WORD, and your problem will be solved.

http://www.biocompsystems.com/_public/DCOMConfigurationStepbyStepForXP.doc

Thanks, Sushil Jinder

查看更多
登录 后发表回答