Form problem with ActiveX DLL called from C#

  • Thread starter Thread starter Ata ?smet ?z?elik
  • Start date Start date
A

Ata ?smet ?z?elik

Hi i am developing a Windows.Forms Application and I am using an
ActiveX dll built in C++.
I define a delegate for the eventhandler built in the DLL and using a
method that is bound to it. My main form is waiting for the event to
be occur. The problem is in the method that is bound to the delegate i
am trying to create a new form such as :

void X()
{
....


frm Form2 = new Form2();
frm.Show();

...



}

My form shows up but when the method X ends, my form is closed
automatically, even if I set the event in the Form2.Closing for
cancelling it, it is closed.
Got anyone any idea?
 
Hi,

Declare the frm variable on the class level, not the method level. Make sure
that you dispose of the form when it's no longer needed.
 
Well I wrote it wrong.
I already defined in the class level so my correct code is :



frm = new Form2();

And frm is defined in the class level.
 
Back
Top