Dear All,
I have create an excel (COM Object) using this code
Excel.Application xls = new Excel.Application();
but I can not remove it from memory although I have using close and quit
wb.Close(false, false, 0);
xls.Quit();
If I open task manager there is excel.exe. If I run multiple time the number
of excel.exe in task manager will increase.
Please Help.
Regards,
Gunawan 6 2047
In article <uB**************@TK2MSFTNGP06.phx.gbl>, jg**********@gmail.com says...
Dear All,
I have create an excel (COM Object) using this code
Excel.Application xls = new Excel.Application();
but I can not remove it from memory although I have using close and quit
wb.Close(false, false, 0);
xls.Quit();
If I open task manager there is excel.exe. If I run multiple time the number
of excel.exe in task manager will increase.
What is "wb"? A reference to a workbook I assume?
Make sure you release every COM object you get a reference to using
Marshal.ReleaseComObject()
Excel.Application xls = new Excel.Application();
try
{
wb = ...
try
{
...
}
finally
{
wb.Close(false, false, 0);
Marshal.ReleaseComObject(wb);
}
}
finally
{
xls.Quit();
Marshal.ReleaseComObject(xls);
}
--
Patrick Steele http://weblogs.asp.net/psteele
Hi Patrick,
I still can not release excel.exe from the memory.
Currenty I am using this code on *.aspx file to response click button.
Is it related to this issue? and I am using visual studio 2003.
Marshal.ReleaseComObject still can not remove excel.exe. :(
Regards,
Gunawan
"Patrick Steele" <pa*****@mvps.orgwrote in message
news:MP************************@msnews.microsoft.c om...
In article <uB**************@TK2MSFTNGP06.phx.gbl>, jg**********@gmail.com says...
>Dear All,
I have create an excel (COM Object) using this code
Excel.Application xls = new Excel.Application();
but I can not remove it from memory although I have using close and quit
wb.Close(false, false, 0); xls.Quit();
If I open task manager there is excel.exe. If I run multiple time the number of excel.exe in task manager will increase.
What is "wb"? A reference to a workbook I assume?
Make sure you release every COM object you get a reference to using
Marshal.ReleaseComObject()
Excel.Application xls = new Excel.Application();
try
{
wb = ...
try
{
...
}
finally
{
wb.Close(false, false, 0);
Marshal.ReleaseComObject(wb);
}
}
finally
{
xls.Quit();
Marshal.ReleaseComObject(xls);
}
--
Patrick Steele http://weblogs.asp.net/psteele
It's more likely that whatever you are doing in Excel is leaving something
open. Are you doing OLE Automation or what? This is a problem *many* people
have when doing OLE Automation with Excel.
For example, I had a problem once and it turned out to be a problem with
Ranges. If you use any kind of Ranges (like
..range(.cells(1,2),.cells(3,4)).merge=true), Excel creates a Range object
behind the scenes, and does not dispose of it. You have to do this:
(Sorry this is VB)
Dim myRange as Range = xlsheet.range(.Cells(1,2),.cells(3,4))
myRange.Merge=True
myRange = Nothing
That's just one example, but it depends on what you're doing. The way I
tracked it down was I commented out every single excel command I was using,
then uncommented them one at a time until I found the culprit. Tedious, but
effective.
So the question is, what are you doing with Excel? Are you just opening it
and closing it, or are you doing something in-between?
Robin S.
Ts'i mahnu uterna ot twan ot geifur hingts uto.
-----------------------------------------------
"Gunawan" <jg**********@gmail.comwrote in message
news:uw*************@TK2MSFTNGP06.phx.gbl...
Hi Patrick,
I still can not release excel.exe from the memory.
Currenty I am using this code on *.aspx file to response click button.
Is it related to this issue? and I am using visual studio 2003.
Marshal.ReleaseComObject still can not remove excel.exe. :(
Regards,
Gunawan
"Patrick Steele" <pa*****@mvps.orgwrote in message
news:MP************************@msnews.microsoft.c om...
>In article <uB**************@TK2MSFTNGP06.phx.gbl>, jg**********@gmail.com says...
>>Dear All,
I have create an excel (COM Object) using this code
Excel.Application xls = new Excel.Application();
but I can not remove it from memory although I have using close and quit
wb.Close(false, false, 0); xls.Quit();
If I open task manager there is excel.exe. If I run multiple time the number of excel.exe in task manager will increase.
What is "wb"? A reference to a workbook I assume?
Make sure you release every COM object you get a reference to using Marshal.ReleaseComObject()
Excel.Application xls = new Excel.Application(); try { wb = ... try { ... } finally { wb.Close(false, false, 0); Marshal.ReleaseComObject(wb); } } finally { xls.Quit(); Marshal.ReleaseComObject(xls); }
-- Patrick Steele http://weblogs.asp.net/psteele
I will try to explain what I am doing with excel file.
I try to open excel file
Open Excel file
---------------
Application xls = new Application();
_Workbook wb = xls.Workbooks.Open(strFilename,
0, true, 5, "", "", true, Excel.XlPlatform.xlWindows,
"\t", false, false, 0 , true, 0, 0);
_Worksheet wsh = (_Worksheet) wb.Worksheets[1];
Retrieving Data
for
{
strKodeBarang = ((Range) wsh.Cells[i,1]).Value2.ToString() ;
strNamaBarang = ((Range) wsh.Cells[i,2]).Value2.ToString() ;
}
Releasing Object
-----------------
Marshal.ReleaseComObject(wsh);
wb.Close(false, false, 0);
Marshal.ReleaseComObject(wb);
xls.Quit();
Marshal.ReleaseComObject(xls);
I use this tehnique using vb6 and no excel.exe retain on memory.
But using C# always left excel.exe in memory.
Regards,
Gun
"RobinS" <Ro****@NoSpam.yah.nonewrote in message
news:HO******************************@comcast.com. ..
It's more likely that whatever you are doing in Excel is leaving something
open. Are you doing OLE Automation or what? This is a problem *many*
people have when doing OLE Automation with Excel.
For example, I had a problem once and it turned out to be a problem with
Ranges. If you use any kind of Ranges (like
.range(.cells(1,2),.cells(3,4)).merge=true), Excel creates a Range object
behind the scenes, and does not dispose of it. You have to do this:
(Sorry this is VB)
Dim myRange as Range = xlsheet.range(.Cells(1,2),.cells(3,4))
myRange.Merge=True
myRange = Nothing
That's just one example, but it depends on what you're doing. The way I
tracked it down was I commented out every single excel command I was
using, then uncommented them one at a time until I found the culprit.
Tedious, but effective.
So the question is, what are you doing with Excel? Are you just opening it
and closing it, or are you doing something in-between?
Robin S.
Ts'i mahnu uterna ot twan ot geifur hingts uto.
-----------------------------------------------
"Gunawan" <jg**********@gmail.comwrote in message
news:uw*************@TK2MSFTNGP06.phx.gbl...
>Hi Patrick, I still can not release excel.exe from the memory.
Currenty I am using this code on *.aspx file to response click button.
Is it related to this issue? and I am using visual studio 2003. Marshal.ReleaseComObject still can not remove excel.exe. :( Regards, Gunawan
"Patrick Steele" <pa*****@mvps.orgwrote in message news:MP************************@msnews.microsoft. com...
>>In article <uB**************@TK2MSFTNGP06.phx.gbl>, jg**********@gmail.com says... Dear All,
I have create an excel (COM Object) using this code
Excel.Application xls = new Excel.Application();
but I can not remove it from memory although I have using close and quit
wb.Close(false, false, 0); xls.Quit();
If I open task manager there is excel.exe. If I run multiple time the number of excel.exe in task manager will increase.
What is "wb"? A reference to a workbook I assume?
Make sure you release every COM object you get a reference to using Marshal.ReleaseComObject()
Excel.Application xls = new Excel.Application(); try { wb = ... try { ... } finally { wb.Close(false, false, 0); Marshal.ReleaseComObject(wb); } } finally { xls.Quit(); Marshal.ReleaseComObject(xls); }
-- Patrick Steele http://weblogs.asp.net/psteele
"Gunawan" <jg**********@gmail.comwrote in message
news:eZ**************@TK2MSFTNGP03.phx.gbl...
>I will try to explain what I am doing with excel file.
I try to open excel file
Open Excel file
---------------
Application xls = new Application();
_Workbook wb = xls.Workbooks.Open(strFilename,
0, true, 5, "", "", true, Excel.XlPlatform.xlWindows,
"\t", false, false, 0 , true, 0, 0);
_Worksheet wsh = (_Worksheet) wb.Worksheets[1];
Retrieving Data
for
{
strKodeBarang = ((Range) wsh.Cells[i,1]).Value2.ToString() ;
strNamaBarang = ((Range) wsh.Cells[i,2]).Value2.ToString() ;
}
Releasing Object
-----------------
Marshal.ReleaseComObject(wsh);
wb.Close(false, false, 0);
Marshal.ReleaseComObject(wb);
Should be...
xls.Quit();
GC.Collect();
GC.WaitForPendingFinalizers();
Anyway, you should know that this is an unsupported scenario for Office application,
especially in .NET as you can never rely on the Finalizer to release all outstanding COM
references. http://support.microsoft.com/kb/257757
Willy. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
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...
|
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...
|
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#...
|
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...
|
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...
|
by: Anthony |
last post by:
To me, creating Excel 2003 spreadsheets programmatically via VB.NET hasn't
really changed since the days of VB6.
That is, I'd do something similar to this
Code:
Dim ExcelApp As...
|
by: Alain \Mbuna\ |
last post by:
Hi everybody.
In my program I have some data that is calculated after some input from the
user. I have written some code that opens an Excel workbook, with 5
worksheets and the calculated data...
|
by: alexia.bee |
last post by:
Hi all,
In some weird reason, excel instance won;t die if i remove the comment
from 4 lines of setting values into struct.
here is a snipcode
public...
|
by: Doug Glancy |
last post by:
I got the following code from Francesco Balena's site, for disposing of Com
objects:
Sub SetNothing(Of T)(ByRef obj As T)
' Dispose of the object if possible
If obj IsNot Nothing AndAlso...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
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...
| |