1

I have used Microsoft.office.interop.word dll to view word document and it is working fine on code level debugging but after publishing my project on the same machine i am getting this exception while creating the dll object

retrieving the COM class factory for component wit CLSID {000209FF-0000-0000-C000-00000000046} failed due to the following error : 80070005

Didn't find any solutions yet on web .. kindly help me

Shadow The GPT Wizard
  • 66,030
  • 26
  • 140
  • 208
Osama Khalid
  • 13
  • 2
  • 7
  • `80070005` is the access denied error. – Rahul May 21 '13 at 06:59
  • Rahul can u please guide me how to solve this ..!! i have done almost everything to grand permission to dll , i have created new users as well and check the allow all field .. but still receiving the same – Osama Khalid May 21 '13 at 07:14
  • after pulishing your project you are putting it on server or on different machine. – Rahul May 21 '13 at 07:17
  • no .. i am publishing it on my machine , IIS server locally – Osama Khalid May 21 '13 at 08:12
  • i read somewhere that office must be installed on the server where i have to publish , but i am publishing it on my machine – Osama Khalid May 21 '13 at 08:13
  • that's why i m asking for you that where you putting your project,,because i knew this thing that if you put your project on server then make sure that office must be install there,,but u r saying that everything is fine and u r put it locally on `IIS`.. – Rahul May 21 '13 at 08:51
  • yes ...!! please tell me any solution if you know any – Osama Khalid May 21 '13 at 09:41
  • http://stackoverflow.com/questions/1491123/system-unauthorizedaccessexception-retrieving-the-com-class-factory-for-word-in – Rahul May 21 '13 at 09:43
  • http://stackoverflow.com/questions/1190600/retrieving-the-com-class-factory-for-component-error-while-generating-word-docum – Rahul May 21 '13 at 09:44
  • It looks like a permission/rights issue to me. – DayTimeCoder May 21 '13 at 09:45
  • dotnetsoldier .. i know that .. please provide me with some solution – Osama Khalid May 21 '13 at 09:47
  • 1
    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 May 22 '13 at 06:31
  • Good question +1 for that... – DayTimeCoder May 22 '13 at 09:36
  • @JohnSaunders I agree with your point, but he is probably working on an older app or fixing some code. – DayTimeCoder Feb 17 '17 at 03:00
  • 1
    @owais or it could as easily been a new application. It doesn't really matter. It's _still_ a horrible idea. It is meant for desktop apps, which are not multithreaded. ASP.NET runs each request on a different thread, which can be a disaster. – John Saunders Feb 18 '17 at 04:50
  • 1
    @owais I learned this the hard way when I was told to fix the memory leak in an app. Turns out no memory leak. C runtime library was not reentrant. As soon as "malloc" was run on a second thread, the entire heap was corrupted. From then on it was a exception for every reference to the heap. Of course then the exception was ignored which is a separate thing to never do. – John Saunders Feb 18 '17 at 04:53
  • @JohnSaunders Thanks for sharing your experience,I will keep this in mind. – DayTimeCoder Feb 20 '17 at 09:51

1 Answers1

0

Try this:

  1. Goto Start > Run > dcomcnfg 64
  2. Console Root > Component Services > My Computer > DCOM Config
  3. Choose Details View for easy navigation.
  4. Find Excel and Word
  5. Right click > Properties
  6. On the security tab: Select Customize under Launch and Activation Permissions and click Edit…
  7. Add the account under which the site is running (eg: Network Service) and assign Local Launch & Local Activation permissions and Also Add IIS_IUSRS and give full permissions.

Snapshots
Step 2
enter image description here
Step 3
enter image description here
Step 4
enter image description here

P.S: Adapted and modified from SO Post

Community
  • 1
  • 1
DayTimeCoder
  • 4,294
  • 5
  • 38
  • 61