The GC thing had me wondering too, but I can verify empirically that the
resources are never freed if I don't call it directly, and my customers curse
my application in the afternoon when it brings their 2GB PCs to their knees.
But that aside, I would expect that it is acceptable to call the Dispose
method in this situation (the reason we would have to could be relevant, or
that could be a separate question altogether), so my question remains as to
why the dll is crashing when a new instance of the drawing surface is
initialized.
I determined that the crash doesn't happen unless the last instance of the
control is destroyed. So I can work around the problem by declaring an
instance of my UserControl (with the drawing surface) that never gets
destroyed. This is an acceptable, though ugly, workaround for the issue at
hand, but I hope this information could help lead to a more appropriate
solution.
[quoted text, click to view] ""Peter Huang" [MSFT]" wrote:
> Hi
>
> Based on my understanding, I assume the c is a UserControl when you want to
> dispose it in the second line.
>
> Panel1.Controls.Clear()
> c.Dispose()
> c = New UserControl1
> Panel1.Controls.Add(c)
> c.Src = System.IO.Directory.GetCurrentDirectory & "\test1.vsd"
>
> I just wonder why you need to call the Dispose method here explictly.
> Also GC has its own algorithm to schedule when to run, because a keep
> running GC thread will hit the performance.
>
> Commonly we implement the IDispose and call the Dispose when we want to
> release the Unmanaged Resource, because GC have no idea about the unmanaged
> world. It managed the Managed Resource. GC did the job that call the
> Finalize, commonly is the deconstructor in the C++ term. Commonly we did
> not need to explicitly call the Finalize, it is handled by GC.
>
> Here is link for your reference.
> Garbage Collection: Automatic Memory Management in the Microsoft .NET
> Framework
>
http://msdn.microsoft.com/msdnmag/issues/1100/gci/ > Garbage Collection¡ªPart 2: Automatic Memory Management in the Microsoft
> .NET Framework
>
http://msdn.microsoft.com/msdnmag/issues/1200/GCI2/default.aspx >
> Resource Management
>
http://msdn2.microsoft.com/en-us/library(d=robot)/22d8keek.aspx
>
> Best regards,
>
> Peter Huang
> Microsoft Online Partner Support
>
> Get Secure! -
www.microsoft.com/security > This posting is provided "AS IS" with no warranties, and confers no rights.
>
Hi,
Commonly for a winform application, in the application's lifetime, once we
create a usercontrol, we did not destroy it until when the winform
application exited. But that will cause a lot of resource recreate which
will hit the performance.
So I just wonder why we need to create/destroy the usercontrol frequently.
Did you have special requirement?
e.g. you will show your customers two visio files in the meantime, we just
need to create two instance visio control and change the view by changing
the Src property of the control.
For your scenario about why it will crash, based on my experience, a
problem as complex as this may take extensive time to narrow down. Also it
needs lower level debugging or dump analysis. I think you may need to work
with Microsoft Customer Service and Support (CSS) for a faster resolution.
Once you open a Support incident with Microsoft CSS, a dedicated Support
Professional can work with you in a more efficient manner.
http://support.microsoft.com Thanks for your understanding!
Best regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! -
www.microsoft.com/security This posting is provided "AS IS" with no warranties, and confers no rights.