Damn! - ocx gets unregistered when .net application is uninstalled.

  • Thread starter Thread starter Vinay
  • Start date Start date
V

Vinay

Hi,
I am a VB programmer moving into .NET programming

I'm facing a problem here. I have used a flexgrid (COM using Interop) in a
Vb.net application and it works fine. I have created a setup file and this
is also not a problem.

The problem comes when I use unregister this application. the ocx file is
automatically unregistered even though other application use the MS
flexgrid. This causes problems in all other applications and I have to
register this ocx again.

Any idea what I should do here.

Thanx,

Vins
 
This is an inherent problem with COM, and I'm going to guess that something
else installed and registered the OCX without using Windows Installer,
which clobbers ref-counting.

I can't think of a great workaround other than to not have your Setup
project register the .OCX at all. This is a pretty hacky solution since
there are probably scenarios where your uninstall will remove the .OCX file
and break apps using that instance. You could add code to your .NET app
that would try to create the object,, and if that that threw an exception
try to register your local copy. Something like this maybe
Try
Dim x As Object = CreateObject("MyProgId")
Catch ex As Exception
Process.Start("regsvr32.exe myctrl.ocx").WaitForExit
Dim x As Object = CreateObject("MyProgId")
End Try

Good luck. If you can move your controls to .NET assemblies instead (and I
believe a lot of the 3rd party control vendors have FlexGrid controls),
you'll completely avoid this kind of issue. The .NET Frameworks system was
designed precisely to avoid this situation.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top