473,654 Members | 3,280 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

cominterop excel and c#

Hi
in my app im working with excel using cominterop when fished my work with
excel i execute this code

oWB.Close(null, null,null);
oXL.Workbooks.C lose();
oXL.Quit();
System.Runtime. InteropServices .Marshal.Releas eComObject (oXL);
System.Runtime. InteropServices .Marshal.Releas eComObject (oSheet);
System.Runtime. InteropServices .Marshal.Releas eComObject (oWB);
oSheet=null;
oWB=null;
oXL = null;
GC.Collect();
but Excel.exe still remains in memory untill i unload my exe, any ideas?

Thanks
Nov 16 '05 #1
4 2204
Ariel,
but Excel.exe still remains in memory untill i unload my exe, any ideas?


There are still intermediate objects (such as the Workbooks
collection) that haven't been released, and they might keep Excel
running.

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Nov 16 '05 #2
But Mattias,

In his code he's closed the workbooks, shut down Excel, released the
associated COM objects, and set them to null. So in what sense are there
any intermediate objects that haven't been released??

And in any event -- what would the solution be?

--Bob

"Mattias Sjögren" <ma************ ********@mvps.o rg> wrote in message
news:%2******** ********@TK2MSF TNGP10.phx.gbl. ..
Ariel,
but Excel.exe still remains in memory untill i unload my exe, any ideas?


There are still intermediate objects (such as the Workbooks
collection) that haven't been released, and they might keep Excel
running.

Mattias

Nov 16 '05 #3
Thanks Mattias and Bob, i dont know whats happen, but affortunately, build
release mode and running the executable closes the excel completely, the
problem was when running in debug mode from the vs.net 2003 ide

"Bob Grommes" <bo*@bobgrommes .com> wrote in message
news:eG******** ******@TK2MSFTN GP09.phx.gbl...
But Mattias,

In his code he's closed the workbooks, shut down Excel, released the
associated COM objects, and set them to null. So in what sense are there
any intermediate objects that haven't been released??

And in any event -- what would the solution be?

--Bob

"Mattias Sjögren" <ma************ ********@mvps.o rg> wrote in message
news:%2******** ********@TK2MSF TNGP10.phx.gbl. ..
Ariel,
but Excel.exe still remains in memory untill i unload my exe, any
ideas?
There are still intermediate objects (such as the Workbooks
collection) that haven't been released, and they might keep Excel
running.

Mattias


Nov 16 '05 #4
Bob,
In his code he's closed the workbooks,
Right, but not the workbook collection object returned here

oXL.Workbooks.C lose();
^^^^^^^^^

To release that object you'd have to do

Excel.Workbooks wbs = oXL.Workbooks;
wbs.Close();
Marshal.Release ComObject(wbs);

And in any event -- what would the solution be?


Be really careful to release everything object you touch (which can
make the code really ugly) or force a garbage collection after you're
done with all the objects. Neither way is really good.

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Nov 16 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
35524
by: Allison Bailey | last post by:
Hi Folks, I'm a brand new Python programmer, so please point me in the right direction if this is not the best forum for this question.... I would like to open an existing MS Excel spreadsheet and extract information from specific worksheets and cells. I'm not really sure how to get started with this process. I ran the COM Makepy utility from my PythonWin (IDE from ActiveSTate),
2
1844
by: me | last post by:
What is the downside of Cominterop? is it good practice? what does it do to memory? Thanks
3
20275
by: Otie | last post by:
I found the following under the GetObject help notes and in the example for GetObject: "This example uses the GetObject function to get a reference to a specific Microsoft Excel worksheet (MyXL). It uses the worksheet's Application property to make Microsoft Excel visible, to close it, and so on. Using two API calls, the DetectExcel Sub procedure looks for Microsoft Excel, and if it is running, enters it in the Running Object Table. The...
6
12488
by: Matthew Wieder | last post by:
I have the following requirements: Build a stand-alone C# application that asks the user to click in a cell in an Excel spreadsheet, and then displays the address of that cell in the C# application. It seems simple enough, but the problem I'm encountering is as follows: In order for the user to select the cell from Excel, they must first click once on the Excel window to give it focus and then their second click is what changes the cell...
0
1150
by: Mário Sobral | last post by:
Hi ! I have developed a .NET library that references another .NET library. MyLibrary -> OtherLibrary I then create a COMInterop wrapper assembly to use it from a VB6 project:
14
5782
by: pmud | last post by:
Hi, I need to use an Excel Sheet in ASP.NET application so that the users can enter (copy, paste ) large number of rows in this Excel Sheet. Also, Whatever the USER ENETRS needs to go to the SQL DATABASE, probably by the click of a button. Is this possible? & what is the BEST APPROACH for doing this? & also if any links are there do tell those to me too coz I have no idea how to go about doing it.
22
15329
by: Howard Kaikow | last post by:
There's a significant problem in automating Excel from VB .NET. Reminds me of a problem I encountered almost 3 years ago that was caused by the Norton Auntie Virus Office plug-in. Can anybody reproduce the behavior described below? For this example, I am using Excel 2002 and VS .NET 2002 and VB 6. MSFT KB article 304661 gives a trivial example of early and late binding to Excel from VB .NET. Note that there is a variable naming...
1
1364
by: info | last post by:
Hi I've an C# .NET 2.0 Windows Forms Application which is placed in an DLL. This DLL is instanciated from an non .NET enviroment via ComInterop. This works fine. but I need to put the wohle .NET Application in an second thread so that both applicaitons .NET and non .NET are responsive.
0
8290
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8708
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8594
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7307
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5622
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4149
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4294
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2716
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1596
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.