Question:
I would like to ask a question to answer questions to clear Excel interop items There were several solutions (as if wrappers do not use more than one point, kill excel processing), but I like the problem most ().
What it basically says is that you do not worry too much about floating around all contexts. You are just a few key people (like ApplicationClass
, workbook
and worksheet
). You first prepare garbage collection to clear all the objects and then clear your main references by clearly calling Marshal.FinalReleaseComObject
(in the opposite order of importance).
Now I have two questions about this.
First: How can I determine which object I need to keep reference to? In it, it only keeps limits
, worksheets
, workbooks
and ApplicationClasses
. Second: If there are more objects
update 1:
P> Recommended by Matasy
The only important thing is that the app is released for the last time, though in my following sentence: "You must also release your named reference in the order of importance mentioned: Range objects first, worksheets, workbooks, And then finally your Excel application object. " This means that there is more ordering.
nobugz
indicates that setting everything to null
and then collecting garbage will be enough, but it seems that the contrasts with the lower quote Is: "You will think, then, you can set all your variables = nothing
and then call GC.Collect ()
in the end, and this is sometimes However, Microsoft Office applications are unfortunately, setting your variable = nothing
and then GC.Collect ()
caller CTO's release does not guarantee orders.. "
Update 2:
Some additional information: In my application, I do so many things with a chart. I am establishing many properties etc. As I think, there are many places where I create a new com object, I tried to make sure that I never used double dots, and I did not have to use the Marshall.FinalRailCom object
I tried to call those who ended with me. I did not use the cover approach because it would present a lot of nesting victim.
Excel Exe opened
which was not closed. Now I have removed everything from Marshall. Funierrech Com Objects
Calls and apps do exactly the same thing. EXCEL.exe
remains, unless I tell my app to do the job again, but then a new EXCEL.exe
starts and stays Edit: Also, when I tell my app to perform other non-com related tasks, after some time, EXCEL.exe
disappears, but now no new EXCEL.exe
You have no problem finding potential references in your code Minister should, they will field in your class (SAS). Or local variable in cleanup method, it is not possible that the list given in the links is just the object, which you will likely have to store in a field. Others may also be able to keep Excel as the only thing to keep alive as a commodity object.
I do not think I recommend Jackman approach to advocating links, it hides a potential life reference, for an RCW that wraps up a dead COM interface, the best you can do for the RCW object In the worst, it crashes your program with an exception when it accidentally references the object. Bugs, to make sure that you can easily find them. All you have to do is set to clear your references, the order does not make any difference, then it is gathered.
No comments:
Post a Comment