PC Review


Reply
Thread Tools Rate Thread

after debug "Can't write dll because a process has it open"

 
 
mp
Guest
Posts: n/a
 
      25th Apr 2010
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




 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Receiving Error: Unable to copy file "obj\Debug\MyProject.xml" to "bin\Debug\MyProject.xml". Access to the path 'obj\Debug\Aegis.xml' is denied. Aegis CGatto Microsoft VB .NET 4 24th Jul 2010 12:09 AM
Debug process for "you may not have access rights...." ***** charles Windows XP Networking 2 3rd Nov 2006 02:27 AM
Error: "only part of read process memory or write process memory" =?Utf-8?B?amVmZmFsbGVu?= Windows XP Help 1 1st Jul 2004 12:16 AM
<FORM METHOD="post" onSubmit="return fieldcheck()" name="orientation" action="http://ws-kitty.BU.edu/AT/survey/orientation/script/write.asp" language="JavaScript"> Joeyej Microsoft ASP .NET 0 4th Jun 2004 08:55 PM
"The process cannot access the file" when trying to write to filethe second time... FrzzMan Microsoft C# .NET 2 13th Apr 2004 05:30 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:37 AM.