Count Down

 

تعليقات

How to run Excel Com or any com from ASP.net Site

While I build some web site one of its requirements to use excel files as data input where user upload as Excel workbook or even download it, every thing was excellant on development machine works 100% but when I moved site to server it gave me huge error that tell me no access permession to use COM from IIS or asp.net so after lot of search where they only told use this tool without how or what but I managed finally to run it perfectly I hope, I descied to wrote it down to help other people how face the same problem in futuer:

 Error message look somthing like that:

 

Retrieving the COM class factory for component with CLSID {00024500-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 {00024500-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 , 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.

 

The solution as following steps:

  1.  goto start=> Run and print out dcomcnfg, Component Services Window will open showing to section left pane contain Component Services, Event Viewr, Services(local).

  2. Expand Component Services after that expand Computers, MyComputer

  3. After last expand we did will appear following groups COM+ Applications, DCOM config, Distributed Transaction Coordinator and Running Processes we will select DCOM config, and start looking for our target COM in my case was Microsoft Excel Application.

  4. After we find it we click right click select properties and move directly to Security tab, then move on each one as shown below:

    1. Lunch and Activation Permission’s select Customize then edit and add our ASP.NET user account

    2. Access Permission’s select Customize then edit and add our ASP.NET user account

  5.   Fin now our web application can access our target COM and work as required and needed.

تعليقات

С Новым Годом

ny_171.jpg

تعليقات

Happy Eid

 ad7a2007mmh.jpg

تعليقات