M
Mk23
Hi
I'm programming an excel (Ver. 2007) addin in c#. The addin connect to a
database and set up a graphical dashboard for the data, by manipulating the
graphical style of a huge number of cells.
The problem is that the amount of memory is just increasing, so that i get a
out of memory exception. I thought that i do the releasing of the COM Object
right, but it doesn't work (see Code snippet). Also a call to GC.Collect()
doesn't help.
protected void SetBorder(Excel.Range rng, Excel.XlBordersIndex
borderType)
{
Excel.Borders borders = rng.Borders;
Excel.Border border = borders.get_Item(borderType);
border.LineStyle = Excel.XlLineStyle.xlContinuous;
border.Weight = Excel.XlBorderWeight.xlHairline;
border.ColorIndex = 1;
Marshal.ReleaseComObject(border);
Marshal.ReleaseComObject(borders);
border = null;
borders = null;
}
What can i do to save memory?
Best regards
Thomas
I'm programming an excel (Ver. 2007) addin in c#. The addin connect to a
database and set up a graphical dashboard for the data, by manipulating the
graphical style of a huge number of cells.
The problem is that the amount of memory is just increasing, so that i get a
out of memory exception. I thought that i do the releasing of the COM Object
right, but it doesn't work (see Code snippet). Also a call to GC.Collect()
doesn't help.
protected void SetBorder(Excel.Range rng, Excel.XlBordersIndex
borderType)
{
Excel.Borders borders = rng.Borders;
Excel.Border border = borders.get_Item(borderType);
border.LineStyle = Excel.XlLineStyle.xlContinuous;
border.Weight = Excel.XlBorderWeight.xlHairline;
border.ColorIndex = 1;
Marshal.ReleaseComObject(border);
Marshal.ReleaseComObject(borders);
border = null;
borders = null;
}
What can i do to save memory?
Best regards
Thomas