Tech
Forums
Jobs
Books
Events
Videos
Live
More
Interviews
Certification
Training
Career
Members
News
Blogs
Contribute
An Article
A Blog
A Video
An Ebook
An Interview Question
Register
Login
2
Answers
Not able to clear the Excel.exe even after the System.Runtime.InteropServices.Marshal.FinalReleaseComObject(obj) in c#
Aurosish Mohanty
13y
4.2k
1
Reply
Hi all,
I am struggling a lot while trying to close the Excel sheet and any Excel object using the
System.Runtime.InteropServices.
Marshal
.FinalReleaseComObject(obj)
Even though I am using the below code, the EXCEL.EXE is still running in the back , so not able to open and modify the Excel sheet.
Please help me ............. Need your quick response.
private
{
static
void
releaseObject(
object
obj)
try
{
System.Runtime.InteropServices.
obj =
}
{
obj =
}
GC
.Collect();
GC
.WaitForPendingFinalizers();
GC
.Collect();
GC
.WaitForPendingFinalizers();
Marshal
.FinalReleaseComObject(obj);
null
;
catch
(
Exception
ex)
null
;
finally
{
{
System.Runtime.InteropServices.
System.Threading.
}
}
}
if
(obj !=
null
)
Marshal
.FinalReleaseComObject(obj);
Thread
.Sleep(5000);
Post
Reset
Cancel
Answers (
2
)
Next Recommended Forum
MAPI32.DLL
c# web app using Windows Image Acquisition (WIA) in Windows Server 2008