NullReferenceException at IConnectionPoint.Unadvise

  • Thread starter Thread starter Stephen
  • Start date Start date
S

Stephen

Could someone help me figure out this (unhandled) exception I am receiving
every time I shut down my windows service. I have made my service
interactive and have created a form (which doesn't get shown) and added a
third party activeX control to it. If I remove the activeX control the
service shuts down fine.

I am writing all unhandled exceptions to the event log. Every time I stop
the service I see two of the following exceptions:

System.NullReferenceException: Object reference not set to an instance of an
object.
at System.Windows.Forms.IConnectionPoint.Unadvise(Int32 cookie)
at System.Windows.Forms.ConnectionPointCookie.Disconnect()
at System.Windows.Forms.ConnectionPointCookie.Finalize()

plus one that looks like:

System.NullReferenceException: Object reference not set to an instance of an
object.
at System.Windows.Forms.IConnectionPoint.Unadvise(Int32 cookie)
at System.Windows.Forms.ConnectionPointCookie.Disconnect()
at System.Windows.Forms.OleInterfaces.Finalize()
 
Hi Stephen,

The bug happens when the runtime asks the COM component to shut down,
apparently during garbage collection, and the component says "I never
started... how can I shut down." It's a bug in your ActiveX control.

I'm still trying to figure out why you have a form in a windows service.
Can't you create your form in a stand-alone application that can get the
information it wants from the windows service through .NET Remoting?

(Think: SQL Server. The service has no dialog, but you can run a couple of
different interfaces to start and monitor that service.
Take a look at the Microsoft.ApplicationBlocks.Log object, which gives you
instrumentation capabilities. Or, just read up on .Net Remoting.)

Good Luck,
--- Nick
 
Thanks for the reply!

I tried this with a few different ActiveX controls and they all have the
same problem. Perhaps a bug in all ActiveX controls used from .NET?

I've found that calling the Dispose method of the ActiveX control (something
which I didn't have to do when it was running as an application) fixes the
problem.
 
Back
Top