Issue of publishing Excel files in Asp.net via template Export

Source: Internet
Author: User

Exception information: failed to retrieve components whose CLSID is {00024500-0000-0000-C000-000000000046} in the COM class factory because of the following error: 8000401a.

Note:

Because the exported Excel template is too complex, you can use the excel control to open the template, enter the data, and then push the file to the client.

No problems were found in the program test, but after the release was successful, the client could not be accessed. What is the problem?

 

First, we find that there is no problem when debugging through vs, so we can infer that the program code is okay, and the problem should occur when the client accesses the server. Therefore, permission issues may occur.

The method found on the internet is consistent, as shown below:

Install office2003 first, and pay attention to adding a pair during installation. Net Support

Next, add references to web. config. You can view the version and Public Key mark in c: \ windows \ assembly.

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

First, modify the permissions of the folder where the excel files are stored, and then in the component service (run -- dcomcnfg ), find "Microsoft Excel application" (in the registry, we can see that the problematic CLSID points to this component), right-click the "Security" tab of "attribute, modify "Start and activation permissions" to "Custom" and "edit" to add Iuser_MachineName-Internet Guest user (determined by <identity impersonate = "true"/> ), grant all permissions. The "access permission" settings are the same as above. Select "Interactive User" in the "ID" tab ".

 

However, after the test, the problem is not solved.

 

According to my judgment, I think the permission settings should be incorrect. With a try, I chose the following user in the tag and specified the Administrator. The problem is solved. But I'm not sure if there are other potential security problems.

 

 

 

Attached online solutions:


Failed to retrieve components whose CLSID is {00024500-0000-0000-C000-000000000046} in the COM class factory because of the following error: 80070005. The solution is as follows:
1: Install the Excel software for office on the server.
2: Enter dcomcnfg.exe in "start"-> "run" to start "Component Service"
3: Double-click "component service"> "computer"> "my computer"> "DCOM configuration"
4. In "DCOM configuration", find "Microsoft Excel application", right-click it, and click "properties". The "Microsoft Excel application properties" dialog box is displayed.
5. Click the "ID" tab and select "Interactive User"
6. Click the "Security" tab, click "Custom" on "Start and activate Permissions", and then click the corresponding "edit" button, in the pop-up "security" dialog box, add a "network service" user (note that you must select the computer name) and grant it the "local start" and "Local activation" permissions.
7: the "Security" label remains. Click "Custom" on "Access Permissions", and then click "edit ", in the pop-up "security" dialog box, add a "network service" user and grant "local access" permission. in this way, we have configured the corresponding Excel DCOM permissions.
 
Note: This is configured on WIN2003. On 2000, it may be because the ASP net user is configured to open the EXCEL file on the server. Therefore, you should write a file to save the exported data to the server, then pass the method to the client, and delete all the Excel files generated on the server each time you call this function.
 
Solution 2:
If the above method cannot solve the problem, it should be a permission problem. Please try the following method:
Use identity simulation in web. config and add <identity impersonate = "true" userName = "your userName" password = "password"/> In the <system. web> section.
</System. web>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.