Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / October 2006

Tip: Looking for answers? Try searching our database.

How to force ExcellApp.Quit() when it's actually called?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
sherifffruitfly - 26 Oct 2006 17:46 GMT
Hi,

I load the contents of an excel sheet into a dataset via the excel
object library (couldn't get the #$%#$^ oledb/ado route to work -
#^$%&^%$ connection strings... grrr.... )

Anyway, after I get the sheet's contents into my dataset, I'd love to
jettison excel. Calling ExcelApp.Quit() has no effect until I exit the
entire application. How can I force excelapp.quit() to take effect when
the line is executed?

thanks!

cdj
Stuart King - 26 Oct 2006 17:53 GMT
Hi cdj,

Are you operating Excel through Late Binding?

I had similar issues to the ones you describe and found that Marshall.ReleaseComObject did the trick.

Hope it helps

Stuart King
Informology Ltd.

> Hi,
>
[quoted text clipped - 10 lines]
>
> cdj
sherifffruitfly - 26 Oct 2006 18:07 GMT
> Hi cdj,
>
> Are you operating Excel through Late Binding?

Hi Stuart -

Thanks for the reply.

My project's references to the Excel 11.0 object library are added
before I compile - I take it that's a "no" to your question?
Stuart King - 27 Oct 2006 18:02 GMT
Hi cdj,

I've tried the approach I gave you using the Microsoft Office
references(Early Binding) and in fact it still gives the desired effect.  I
tried it out in a button click handler on a form.  The following code does
nothing fancy, all it does is show Excel, waits for 5 seconds then quits
Excel again.  If you use Task Manager you should be able to see the excel
process coming alve and then being unloaded from memory

private void button1_Click(object sender, EventArgs e)

{

Microsoft.Office.Interop.Excel.ApplicationClass App = new
Microsoft.Office.Interop.Excel.ApplicationClass();

App.Visible = true;

System.Threading.Thread.Sleep(5000);

App.Quit();

System.Runtime.InteropServices.Marshal.ReleaseComObject(App);

}

Hope this helps.

Stuart King

Informology Ltd.

>> Hi cdj,
>>
[quoted text clipped - 6 lines]
> My project's references to the Excel 11.0 object library are added
> before I compile - I take it that's a "no" to your question?
sherifffruitfly - 31 Oct 2006 20:03 GMT
> System.Runtime.InteropServices.Marshal.ReleaseComObject(App);

That line (which I didn't understand the first time you mentioned it)
solved all problems.

Thanks a million!

cdj

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.