none
80070005 Error from ASP.NET Application

    Question

  • I'm trying to start MS Word from a ASPX page.

    In web.config file I was wrote:

        <identity impersonate="true"
      userName="myUid" password="myPWD" />

    so, the application doesn't run with ASP.NET user, but myUid user.

    This user is Administrator member group.

    When I run the application from a WIN XP Professional client I have the error:

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

    Please, help me.

    Thanks

    Alberto

    Monday, September 04, 2006 4:43 PM

Answers

  • I'm having a simliar issue, although once this issue gets resolved I think I have another issue. I'm trying to use Microsoft Word's spell check in my asp.net app here's the code i'm using ...

     

     

    Code Snippet

    'spell check first then save

    Dim word_server As New Word.Application

    ' Hide the server.

    word_server.Visible = False

    ' Make a Word Document.

    Dim doc As Word.Document = word_server.Documents.Add()

    Dim rng As Word.Range

    ' Make a Range to represent the Document.

    rng = doc.Range()

    For Each ctlText As Control In Page.Form.Controls

    If Left(ctlText.UniqueID, 3) = "txt" And ctlText.Visible Then

     

    Dim thistext

    Dim strText As String = ""

    'Dim tempCtl

    If TypeOf (ctlText) Is HtmlInputText Or TypeOf (ctlText) Is HtmlTextArea Then

    thistext = FindControl(ctlText.UniqueID)

    If Not thistext.attributes("readonly") = "readOnly" Then strText = thistext.Value

    ElseIf TypeOf (ctlText) Is TextBox Then

    thistext = FindControl(ctlText.UniqueID)

    If Not thistext.readonly = True Then strText = thistext.text

    End If

    If Not strText = "" Then

    'Convert()

     

     

    'If ctlText.readonly = False Then

    ' ' Copy the text into the Document.

    rng.Text = strText

    ' rng.Text = ctlText.value

    ' ' Activate the Document and call its CheckSpelling

    ' ' method.

    doc.Activate()

    doc.CheckSpelling()

    'word_server.Visible = False

    ' ' Copy the results back into the TextBox,

    ' ' trimming off trailing CR and LF characters.

    Dim chars() As Char = {CType(vbCr, Char), _

    CType(vbLf, Char)}

    strText = doc.Range().Text.Trim(chars)

    If TypeOf (ctlText) Is HtmlInputText Or TypeOf (ctlText) Is HtmlTextArea Then

    thistext = FindControl(ctlText.UniqueID)

    thistext.Value = strText

    Else

    thistext = FindControl(ctlText.UniqueID)

    thistext.text = strText

    End If

    ' ctlText.Value = doc.Range().Text.Trim(chars)

    End If

    End If

    Next

     

     

    ' Close the Document, not saving changes.

    doc.Close(SaveChanges:=False)

    ' Close the Word server.

    word_server.Quit()

     

    The code runs PERFECT when i'm debugging through VS. But then when I upload it to my webserver i get the error "Retrieving the COM class factory for component with CLSID {000209FF-0000-0000-C000-000000000046} failed due to the following error: 80070005. 

     

    With Supporting Details of:

    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.

    ASP.NET is not authorized to access the requested resource. Consider granting access rights to the resource to the ASP.NET request identity. ASP.NET has a base process identity (typically {MACHINE}\ASPNET on IIS 5 or Network Service on IIS 6) that is used if the application is not impersonating. If the application is impersonating via <identity impersonate="true"/>, the identity will be the anonymous user (typically IUSR_MACHINENAME) or the authenticated request user.

    To grant ASP.NET access to a file, right-click the file in Explorer, choose "Properties" and select the Security tab. Click "Add" to add the appropriate user or group. Highlight the ASP.NET account, and check the boxes for the desired access.


    Source Error:

    Line 454:        'spell check first then save
    Line 455:
    Line 456:        Dim word_server As New Word.Application
    Line 457:
    Line 458:        ' Hide the server.

     

     

    I've explicity set FULL access to the dll files that got imported into my app when i set the reference for the Word Com Object for the IUSR_[machine name] account for my web server.

    I even tried using the server's copy of the dll files as the reference file in my project instead of the local dll files, still worked in VS 2k5 but not when on the web server.

     

    I'm not too familiar with com objects and dlls as with regards to asp.net applications. Please offer some insight on the matter. I even tried registering these dlls on the server but i got the cannot find entry point error. Anyone have any idea what's going on?

    Wednesday, April 25, 2007 3:35 AM

All replies

  • The error is access denied.  Try opening Word directly as the specified user on the server and see if you can do it.  Can you post the code you are using?

    Michael Taylor - 9/4/06
    Monday, September 04, 2006 9:45 PM
    Moderator
  • hi,

    I m also getting the same error. the way u told i did that also.its working fine.plz help needed.


    thanx in advance.
    Wednesday, September 06, 2006 9:11 AM
  • Ensure that you are running your app under the context of a specific user by verifying the identity element has impersonate set to true.  Then use userName and password to set the user name and password of a valid account.  Note that you should use a local, restricted account if at all possible to avoid potential security issues.  Also be aware that W2K does not support impersonation of a specific user so you can enable impersonation but it'll use the ASP.NET account instead.  Refer to the articles in MSDN for more info.

    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconASPNETImpersonation.asp
    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/gngrfidentitysection.asp

    Note also that Office generally tries to bring up licensing agreement for each user so this can cause problems.  Open Word using the account you specified on the machine before running your site.  If the user can not open Word outside of ASP.NET then it won't work inside either.

    Are you trying to open a document or just Word itself?  Can you post the code you are using?  Does it work if you use the standard ASP.NET account?

    Michael Taylor - 9/8/06

    Friday, September 08, 2006 12:39 PM
    Moderator
  • I'm having this same problem, and the impersonation thing doesn't seem to help.  I suspect it's because my server is Windows 64-bit.  I've doublechecked all the permissions documents I can find and granted access to everyone, but I'm not getting any progress.
    Friday, April 20, 2007 7:02 PM
  • I'm having a simliar issue, although once this issue gets resolved I think I have another issue. I'm trying to use Microsoft Word's spell check in my asp.net app here's the code i'm using ...

     

     

    Code Snippet

    'spell check first then save

    Dim word_server As New Word.Application

    ' Hide the server.

    word_server.Visible = False

    ' Make a Word Document.

    Dim doc As Word.Document = word_server.Documents.Add()

    Dim rng As Word.Range

    ' Make a Range to represent the Document.

    rng = doc.Range()

    For Each ctlText As Control In Page.Form.Controls

    If Left(ctlText.UniqueID, 3) = "txt" And ctlText.Visible Then

     

    Dim thistext

    Dim strText As String = ""

    'Dim tempCtl

    If TypeOf (ctlText) Is HtmlInputText Or TypeOf (ctlText) Is HtmlTextArea Then

    thistext = FindControl(ctlText.UniqueID)

    If Not thistext.attributes("readonly") = "readOnly" Then strText = thistext.Value

    ElseIf TypeOf (ctlText) Is TextBox Then

    thistext = FindControl(ctlText.UniqueID)

    If Not thistext.readonly = True Then strText = thistext.text

    End If

    If Not strText = "" Then

    'Convert()

     

     

    'If ctlText.readonly = False Then

    ' ' Copy the text into the Document.

    rng.Text = strText

    ' rng.Text = ctlText.value

    ' ' Activate the Document and call its CheckSpelling

    ' ' method.

    doc.Activate()

    doc.CheckSpelling()

    'word_server.Visible = False

    ' ' Copy the results back into the TextBox,

    ' ' trimming off trailing CR and LF characters.

    Dim chars() As Char = {CType(vbCr, Char), _

    CType(vbLf, Char)}

    strText = doc.Range().Text.Trim(chars)

    If TypeOf (ctlText) Is HtmlInputText Or TypeOf (ctlText) Is HtmlTextArea Then

    thistext = FindControl(ctlText.UniqueID)

    thistext.Value = strText

    Else

    thistext = FindControl(ctlText.UniqueID)

    thistext.text = strText

    End If

    ' ctlText.Value = doc.Range().Text.Trim(chars)

    End If

    End If

    Next

     

     

    ' Close the Document, not saving changes.

    doc.Close(SaveChanges:=False)

    ' Close the Word server.

    word_server.Quit()

     

    The code runs PERFECT when i'm debugging through VS. But then when I upload it to my webserver i get the error "Retrieving the COM class factory for component with CLSID {000209FF-0000-0000-C000-000000000046} failed due to the following error: 80070005. 

     

    With Supporting Details of:

    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.

    ASP.NET is not authorized to access the requested resource. Consider granting access rights to the resource to the ASP.NET request identity. ASP.NET has a base process identity (typically {MACHINE}\ASPNET on IIS 5 or Network Service on IIS 6) that is used if the application is not impersonating. If the application is impersonating via <identity impersonate="true"/>, the identity will be the anonymous user (typically IUSR_MACHINENAME) or the authenticated request user.

    To grant ASP.NET access to a file, right-click the file in Explorer, choose "Properties" and select the Security tab. Click "Add" to add the appropriate user or group. Highlight the ASP.NET account, and check the boxes for the desired access.


    Source Error:

    Line 454:        'spell check first then save
    Line 455:
    Line 456:        Dim word_server As New Word.Application
    Line 457:
    Line 458:        ' Hide the server.

     

     

    I've explicity set FULL access to the dll files that got imported into my app when i set the reference for the Word Com Object for the IUSR_[machine name] account for my web server.

    I even tried using the server's copy of the dll files as the reference file in my project instead of the local dll files, still worked in VS 2k5 but not when on the web server.

     

    I'm not too familiar with com objects and dlls as with regards to asp.net applications. Please offer some insight on the matter. I even tried registering these dlls on the server but i got the cannot find entry point error. Anyone have any idea what's going on?

    Wednesday, April 25, 2007 3:35 AM
  •  

    Wednesday, June 13, 2007 2:53 PM
  • I'm not sure if this will help but it was what was giving me the error you have reported.

     

    I had configured (using DCOMCNFG) the permissions for ASPNET account for "Microsoft Word Document" from the DCOM list. However, I had also specified a specific user identity to run as. I had to change this to a higher priviliged account in the past to get this to work. Reverting the setting back to the "launching user" did the trick.

     

    I don't know why changing it previously had made it work, but now was stopping it from working. Perhaps setting or reverting this will solve your problem.

     

    Chris

    Monday, July 16, 2007 2:07 PM
  • I had similar problems. DCOMCNFG allowed the ASPNET account to start MS Word, but then MS Word couldn't find the file (the files were on a network share and ASPNET didn't have access).

     

    Impersonation did the trick for me (I reverted the DCOMCNFG changes) - you have to make sure the account you use (ASPNET or your impersonation) has both access to start MS Word, and also access to the files you are opening.

     

    If the word docs are on the same server as the website, then DCOMCNFG is the better solution (use local file paths) because it is more secure. Otherwise, impersonation is necessary.

    Tuesday, July 31, 2007 7:29 AM
  • Could you say which files needed to be changed?
    thanks in advance
    Saturday, October 06, 2007 7:54 PM
  • Hi Guys,
    Any other suggestion perhahips? I'm facing the same issue on 64-bit Vista and Office 2007.
    I'ld like to point out there is no such thing as MS Word in dcomcnfg.

    Really appreciate & thanks
    Aleksandar
    Tuesday, October 21, 2008 1:04 PM
  • This will probably solve your problem:
    http://support.microsoft.com/kb/288368/

    Bastiaan.
    Friday, November 14, 2008 9:44 AM
  • This is not MS Word but if you go through
    "Control Panel>>Administrative Tools>>Component Services>>Computers>>My Computer>>DCOM Config"
    you will see an option to configure Word com object automation server named as "Microsoft Word Document". you can set permissions on same.

    For more information see:

    http://support.microsoft.com/kb/288368/

    My problem was resolved with Word by adding a registry key as given below:

    REGEDIT4

    [HKEY_CLASSES_ROOT\AppID\WINWORD.EXE]
    "AppID"="{00020906-0000-0000-C000-000000000046}"


    Myself a C# Developer
    Tuesday, February 17, 2009 10:23 AM
  • This is not MS Word but if you go through
    "Control Panel>>Administrative Tools>>Component Services>>Computers>>My Computer>>DCOM Config"
    you will see an option to configure Word com object automation server named as "Microsoft Word Document". you can set permissions on same.

    For more information see:

    http://support.microsoft.com/kb/288368/

    My problem was resolved with Word by adding a registry key as given below:

    REGEDIT4

    [HKEY_CLASSES_ROOT\AppID\WINWORD.EXE]
    "AppID"="{00020906-0000-0000-C000-000000000046}"


    Myself a C# Developer
    I had this issue. My problem was resolved by adding aspnet user to addministrator group .
    Tuesday, June 09, 2009 12:27 PM
  • Thanks heaps for the solution.

    We had the DCOM configured properly and it worked for us on 3 different servers, but on a new server it just kept up with producing the <<Retrieving the COM class factory for component with CLSID {000209FF-0000-0000-C000-000000000046} failed due to the following error: 80070005.>>  error.

    After I changed the AppID Registry key under HKEY_CLASSES_ROOT\AppID\WINWORD.EXE from {18A06B6B-2F3F-4E2B-A611-52BE631B2D22} to {00020906-0000-0000-C000-000000000046} the error has gone.

     

     

     

    Wednesday, July 22, 2009 7:18 AM
  • thanks a lot for you help, I have sovle the problem by your suggestion!
    Wednesday, November 17, 2010 12:02 AM
  • Hi Sepideh Ghanbari,

    Me to facing problem could you please elobrate the solution to solve the problem,

    Please........

    Friday, September 28, 2012 11:10 AM
  • Hi Shevyrov,

    Me to facing problem could you please elobrate the solution to solve the problem,

    Please........
    Friday, September 28, 2012 11:10 AM
  • Hi wucccsk,

    Me to facing problem could you please elobrate the solution to solve the problem,

    Please........
    Friday, September 28, 2012 11:10 AM
  • Try this:

    1. In the command line put DCOMCNFG
    2. Expand Console Root > Component Service > Computers, right-click on My Computer, And Select Properties
    3. In the Tab COM Security > Launch and Activation Permissions Click in Edit Default
    4. Add the User (Ex. IIS_IUSRS) or service
    5. Check Allow Local Launch and Local Activation

    Then Excel, Word and other applications can work, good luck.

    Wednesday, March 05, 2014 7:06 AM
  •  

    Kindly, Any body face the same issue but for Outlook

    where can i find the Outlook application in Dcomcnfg

    Friday, November 27, 2015 7:03 AM
  • Kindly, Any body face the same issue but for Outlook

    where can i find the Outlook application in Dcomcnfg

    thanks for your help in advance

    Friday, November 27, 2015 7:05 AM