Groups | Blog | Home
all groups > dotnet interop > march 2005 >

dotnet interop : ActiveX control, disposing


EggHead
3/18/2005 6:19:16 PM
Hi all,

I am trying to put a Vb6.0 activeX control into a VB.net project. The Vb =
6.0 activeX control works fine in a VB6.0 app.

But the problem comes when I close down the Vb.net app. I get =
the"exception privileged error". I think it is because the ActiveX =
components are not shut down in the necessary order when the application =
ends. I already call dispose and set the control to nothing. So, is =
there a way to force the activeX control unload all dll and component?

Thank you all in advance :)

Fruber Malcome
3/18/2005 7:34:03 PM
Have you tried:
GC.Collect()
GC.WaitForPendingFinalizers()

Performing this twice in a row - just to-be sure?

thanks - Fruber

[quoted text, click to view]
Hi all,

I am trying to put a Vb6.0 activeX control into a VB.net project. The =
Vb 6.0 activeX control works fine in a VB6.0 app.

But the problem comes when I close down the Vb.net app. I get =
the"exception privileged error". I think it is because the ActiveX =
components are not shut down in the necessary order when the application =
ends. I already call dispose and set the control to nothing. So, is =
there a way to force the activeX control unload all dll and component?

Thank you all in advance :)

Scott M.
3/19/2005 10:54:48 AM
Are you calling:=20
System.Runtime.InteropServices.Marshal.ReleaseComObject(comObj) in =
addition=20
to removing the managed references to the com object?

[quoted text, click to view]
Hi all,

I am trying to put a Vb6.0 activeX control into a VB.net project. The =
Vb 6.0 activeX control works fine in a VB6.0 app.

But the problem comes when I close down the Vb.net app. I get =
the"exception privileged error". I think it is because the ActiveX =
components are not shut down in the necessary order when the application =
ends. I already call dispose and set the control to nothing. So, is =
there a way to force the activeX control unload all dll and component?

Thank you all in advance :)

Egghead
3/19/2005 1:34:32 PM
Hi,

yes, the whole nine yards

remove the activeX control
dispose it
call GC
do event
dispose the sub form that has the ActiveX
call GC again
do event

The funny thing is that I do not get the"exception privileged error" =
when I close the sub form. It happens when I close the main form. Also, =
I add the error handleing for Unhandled Exceptions in the main form as =
well.

Anyway, I find out why. I have an orphan pointer inside the ActiveX.

Egghead
[quoted text, click to view]
Have you tried:
GC.Collect()
GC.WaitForPendingFinalizers()

Performing this twice in a row - just to-be sure?

thanks - Fruber

[quoted text, click to view]
Hi all,

I am trying to put a Vb6.0 activeX control into a VB.net project. =
The Vb 6.0 activeX control works fine in a VB6.0 app.

But the problem comes when I close down the Vb.net app. I get =
the"exception privileged error". I think it is because the ActiveX =
components are not shut down in the necessary order when the application =
ends. I already call dispose and set the control to nothing. So, is =
there a way to force the activeX control unload all dll and component?

Thank you all in advance :)

Egghead
3/20/2005 12:00:00 AM
Hi,

I try that, it does not work at all.

Egghead
[quoted text, click to view]
Are you calling:=20
System.Runtime.InteropServices.Marshal.ReleaseComObject(comObj) in =
addition=20
to removing the managed references to the com object?

[quoted text, click to view]
Hi all,

I am trying to put a Vb6.0 activeX control into a VB.net project. =
The Vb 6.0 activeX control works fine in a VB6.0 app.

But the problem comes when I close down the Vb.net app. I get =
the"exception privileged error". I think it is because the ActiveX =
components are not shut down in the necessary order when the application =
ends. I already call dispose and set the control to nothing. So, is =
there a way to force the activeX control unload all dll and component?

Thank you all in advance :)

Grant_Aust
3/20/2005 12:00:00 AM
EggHead, I had the same problem with the AxWebBrowser control, in fact I =
still have the problem. I discovered that it only happens on my Laptop =
and Home PC. I tried a couple of other machines at my work, and the =
app closed with no problem. I think it is a conflict with Visual =
Studio.

EggHead
3/21/2005 3:30:31 PM
If it is not your own ActiveX ctl or you do not have access to the =
source code, it is extreme hard to debug. In my case, I find an orphan =
pointer inside one of my ActiveX ctl's supporting dll. It takes me 1-1/2 =
day :) The bug only happens when I am doing something with the ActiveX =
ctl. The app closed with no problem when I only loaded the ActiveX ctl =
with my .Net app.
Anyway, may be one of the ActiveX WebBrowser control's dll get fix in =
those no problem PC


Egghead
[quoted text, click to view]
EggHead, I had the same problem with the AxWebBrowser control, in fact =
I still have the problem. I discovered that it only happens on my =
Laptop and Home PC. I tried a couple of other machines at my work, and =
the app closed with no problem. I think it is a conflict with Visual =
Studio.

Egghead
3/23/2005 12:00:00 AM
Hi Grant,

I have your problem with my ActiveX ctl this morning. It takes me 1/2 =
day to fix that, and I think you are right. Something wrong with the VS =
's wrapper class. Anyway, it is the clock different in my PC and my =
client PC. I accidentally set my PC clock to April 23,2005 (therefore, =
my activeX's time stamp is April 23,2005), and my client PC has the =
right date.

Egghead

[quoted text, click to view]
If it is not your own ActiveX ctl or you do not have access to the =
source code, it is extreme hard to debug. In my case, I find an orphan =
pointer inside one of my ActiveX ctl's supporting dll. It takes me 1-1/2 =
day :) The bug only happens when I am doing something with the ActiveX =
ctl. The app closed with no problem when I only loaded the ActiveX ctl =
with my .Net app.
Anyway, may be one of the ActiveX WebBrowser control's dll get fix in =
those no problem PC


Egghead
[quoted text, click to view]
EggHead, I had the same problem with the AxWebBrowser control, in =
fact I still have the problem. I discovered that it only happens on my =
Laptop and Home PC. I tried a couple of other machines at my work, and =
the app closed with no problem. I think it is a conflict with Visual =
Studio.

Grant_Aust
3/29/2005 2:02:01 PM
Ok, thanks EggHead. It's not a time problem with the WebBrowser =
control.
I am not trying to fix it now. I just put up with the problem on my =
machine's knowing that it does not happen on my clients.

EggHead
3/30/2005 7:38:44 PM
Hi

I forget to add, it throws an exception "specified case is not valid".

my codes like this:

'it is the same with all the methods
Friend WithEvents AxMYACT1 As AxMYACT_ActiveX.AxMYACT or Dim AxMYACT1 As =
New AxMYACT_ActiveX.AxMYACT or Dim AxMYACT1 As Object

'''
' do my stuff
'''

'than release
Try
System.Runtime.InteropServices.Marshal.ReleaseComObject(Me.AxMYACT1 =
) 'it throws an exception "specified case is not valid"
Catch ex As Exception
System.Windows.Forms.MessageBox.Show(ex.Message)=20
Finally
Me.AxMYACT1 .Dispose()
Me.AxMYACT1 =3D Nothing
End Try

How can I call the release without the exception?

Thanks
Egghead
[quoted text, click to view]
Hi,

I try that, it does not work at all.

Egghead
[quoted text, click to view]
Are you calling:=20
System.Runtime.InteropServices.Marshal.ReleaseComObject(comObj) in =
addition=20
to removing the managed references to the com object?

[quoted text, click to view]
Hi all,

I am trying to put a Vb6.0 activeX control into a VB.net project. =
The Vb 6.0 activeX control works fine in a VB6.0 app.

But the problem comes when I close down the Vb.net app. I get =
the"exception privileged error". I think it is because the ActiveX =
components are not shut down in the necessary order when the application =
ends. I already call dispose and set the control to nothing. So, is =
there a way to force the activeX control unload all dll and component?

Thank you all in advance :)

AddThis Social Bookmark Button