From: mp on
Learning vbnet, working on project that runs inside AutoCAD and connects to
an instance of acad to call methods etc.
If the vb proj bombs due to error(which is often as i'm learning and
experimenting) even if caught in a try/catch , when i close Acad to rebuild
the vbproj, acad closes but is still running in process list.

i'll run a test(of the dotnet app). Close acad. revise dotnet app and
rebuild. Get error "can't rewrite dll because a process has it open" or
something like that. When I look in the process list(task mgr)
acad.exe is still running even though the UI appears to have closed. This
happens only sometimes. Sometimes it closes properly, but much of the time
it won't and I have to restart computer every iteration of
debug/rewrite/test...very annoying :-)

What is the correct method to connect to an external object(in this case an
activex server) so that when you close the external application, it actually
closes and lets go of the net dll so the net dll can be re-written?
I'm guessing that Protected Overrides Sub Finalize is equivalent to the
former vb6 Terminate method?
I'm wondering if i'm not disposing right due to dot net gc differences from
vb6 mem mgmt.
???

what i'm doing now:
'top level, create my mainclass"mcs"
Public Sub Test()
If oMcsClient Is Nothing Then oMcsClient = New MCS
If oMcsClient.Init() Then
oMcsClient.DoSomething()
Else
MsgBox("Initialization failed")
End If
End Sub


...
MCS Class:
Private m_Util as MCSUtil
Private m_acadApp As AcadApplication
....
Function Init() As Boolean
If m_Util Is Nothing Then
m_Util = New MCSUtil(True)
Return m_Util.Init(m_acadApp, True)<---set m_acadApp to an instance
End If
...
'now m_Acad is running instance of Acad
....
then when prog is done, dispose of acad
Protected Overrides Sub Finalize()
m_AcadApp = Nothing
MyBase.Finalize()
End Sub
......


....then in
MCSUtil class:
Private m_AcadApp as AcadApplication
....
Function Init(ByRef m_acad As AcadApplication, ByVal bDebug As Boolean) As
Boolean
m_Debug = bDebug
m_acad = Me.GetAutoCADInstance<-get running isntance of acad and return
in byref var
Init = True
End Function
....
Private Function GetAutoCADInstance() As AcadApplication
Try
'get currently running Autocad object if available
m_AcadApp =
Autodesk.AutoCAD.ApplicationServices.Application.AcadApplication
Catch ex As Exception
Me.Logentry("Failed to get acad application " + ex.Message)
m_AcadApp = Nothing
End Try
Return m_AcadApp
End Function
....
and again... when prog is done, dispose of acad
Protected Overrides Sub Finalize()
m_AcadApp = Nothing
MyBase.Finalize()
End Sub