locked
UnauthorizedAccessException thrown with Excel assembly RRS feed

  • Question

  • User-1183675850 posted

    Friends,
      I am using VS 2008 and working with a .net C# code to import data from an Excel file. I am using Windows 7. The dll assembly I imports to my c# code file looks like 

    using Microsoft.Office.Interop.Excel;

    In my code, I always get an exception thrown at the following line

    MSExcel.Application _excel = new MSExcel.Application();

    The previous code line always returns null from the right code and assigns it to the left variable "_excel", and then thorw exception that can be seen in VS 2008 debugger:

    base      {"Retrieving the COM class factory for component with CLSID {00024500-0000-0000-C000-000000000046} failed due to the following error: 80070005."}           System.SystemException {System.UnauthorizedAccessException}

    Please help. Thank you in advance

    P.S. my web.config file containes the assembly file lines like

    <add assembly="Microsoft.Office.Interop.Excel, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71E9BCE111E9429C"/>
     <add assembly="Office, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71E9BCE111E9429C"/>

     

    Wednesday, July 21, 2010 10:53 AM

Answers

  • User-2005691517 posted

    As the error clearly says, the user account that the web application is running as does not have rights to create an excel object. The following post should help you fix it

    http://blog.crowe.co.nz/archive/2006/03/02/589.aspx

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, July 22, 2010 3:32 AM

All replies

  • User-2005691517 posted

    As the error clearly says, the user account that the web application is running as does not have rights to create an excel object. The following post should help you fix it

    http://blog.crowe.co.nz/archive/2006/03/02/589.aspx

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, July 22, 2010 3:32 AM
  • User-1183675850 posted

    Thank you. 

    Thursday, July 22, 2010 9:41 AM