Excel hangs after closing application in asp.net

This code works fine except for the fact that an instance of excel is still in the task manager on the server after the application is done. I've searched everywhere and no code seems to end the process after the code has been run.

I tried your code but I get the error 'Object reference not set to an instance of an object. ' on every System.Runtime.InteropServices.Marshal.ReleaseComObject() line. Am I creating the objects wrong? Any idea?

doesn't it go off after some time ??? i.e. even if we r forcing garbage collector to clean the memory immediately, i have noticed that in the case of office applications, it still remains alive for some more time in some of the machines

This isn't perfect, but it works most times, I have done extensive research on this subject, and Microsoft admits that Excel Automation isn't really meant to be done with a Client front end ie from a server because Excel wasn't originally designed for this. They have also noted that you mustn't reference methods of objects long hand, so for example if you had this code
oSheet.Range("A1,A2").BorderAround(Excel.XlLineStyle.xlContinuous, Excel.XlBorderWeight.xlMedium, Excel.XlColorIndex.xlColorIndexAutomatic)
You should change it to something like this

In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found. I hope it will be useful.
Problem:
After closing a pop-up window, the parent page should be refreshed automaticall…

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform postback. Many times you might need to perform some action on an ASP.NET po…

Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB.
How Percona can help
Percona can help you determine if Percona Server for MongoDB is the right solution for …