F
Fruber Malcome
I've been working several days to figure out why showing a CustomForm on
Word was causing me problems.
I started to notice that when I removed all the controls and made it a basic
Form, it lasted longer, but eventually it would still kill the code.
I then suspected something else in my code that was probably being garbage
collected, so I use the following lines of code at my document_open
function.
GC.Collect()
GC.WaitFormPendingFinalizers()
Now it seems my code is gone after this, so I assume that when closing the
forms, some garbage collection was going on and at that point it was causing
my application to exit with no exceptions etc.
So my question:
How can I determine what GC.Collect will remove, so that way I can try to
troubleshoot what object is leaving that shouldn't (e.g. some out of scope
variable).
I'm not sure there are any, but I'm just trying to figure it out.
For some additional information: I have a class that has some exposed
document_open and document_close functions that handled all of my word
functionality. I've left the standard template created (by the word wizard
in VSTO) alone and just create an instance of my WordClass (which is a
static member of the OfficeCodeBehind class) in the _Startup.
I pass to it a ref to both the application and document. Those objects are
then set accordingly in my WordClass as members as well. (so that they don't
leave scope).
So I'm not sure if that is the problem, but hopefully this additional
information is helpful to anyone that has seen something like this.
Any help would be really appreciated..
thanks
Word was causing me problems.
I started to notice that when I removed all the controls and made it a basic
Form, it lasted longer, but eventually it would still kill the code.
I then suspected something else in my code that was probably being garbage
collected, so I use the following lines of code at my document_open
function.
GC.Collect()
GC.WaitFormPendingFinalizers()
Now it seems my code is gone after this, so I assume that when closing the
forms, some garbage collection was going on and at that point it was causing
my application to exit with no exceptions etc.
So my question:
How can I determine what GC.Collect will remove, so that way I can try to
troubleshoot what object is leaving that shouldn't (e.g. some out of scope
variable).
I'm not sure there are any, but I'm just trying to figure it out.
For some additional information: I have a class that has some exposed
document_open and document_close functions that handled all of my word
functionality. I've left the standard template created (by the word wizard
in VSTO) alone and just create an instance of my WordClass (which is a
static member of the OfficeCodeBehind class) in the _Startup.
I pass to it a ref to both the application and document. Those objects are
then set accordingly in my WordClass as members as well. (so that they don't
leave scope).
So I'm not sure if that is the problem, but hopefully this additional
information is helpful to anyone that has seen something like this.
Any help would be really appreciated..
thanks