C # how to disable the Excel process in a web project

Source: Internet
Author: User

Today I encountered a problem: I called the Excel COM component in a web program.

Result After each call, the task manager generates an Excel. EXE process.

This can cause fatal memory and CPU usage.

Then I want to close the process or release resources.

Two methods have been tried successively (after the Excel operation ):

1. process. Kill ();

2. gc. Collect ();

Method 1: The system throws an exception and prompts: access is denied.

The second method does not change after execution. The Excel. EXE process in the task manager is still in

 

Then, we made a Google tour.

The query finds that most of the two methods are available on the Internet.

Also, add authentication in the configuration file (I did not try)

No result after searching for a while !!

 

Then delete the above two methods,

Try not to kill or release resources in the Excel Operation Method

After the Excel method is called, for example, bool ret = doexcel ();

Followed by GC. Collect ();

In this case, check the result ---- surprise!

After the Excel. EXE process is released successfully, it is automatically disabled.

[The above is what I encountered below win7. I don't know if this is the case for other server systems]

 

I wish you a 5.1 happiness.

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.