Message 1 of 10
IV2010, Vista 64, CreateObject / CreateInstance, and Killing Processes

Not applicable
10-27-2009
01:15 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I'm writing a program to launch Inventor for the user, and I'm stumbling across a strange COM oddity. Perhaps I'm just overlooking something.
I use the following code to launch Inventor:
{code}
Dim t As Type = Type.GetTypeFromProgID("Inventor.Application")
m_objInventorApplication = CType(Activator.CreateInstance(t), Inventor.Application)
{code}
This starts Inventor just fine. The problem comes with closing it down. The process won't actually shut down if you go File-> Exit Inventor or click the X in the title bar. However, if I use my Application object, I can use .Quit and the process dies. Interestingly, I can also kill the process by invoking a different addin that I wrote that calls the .Quit function.
Telling Inventor itself to close will not end its process.
I believe this to be similar to the case in this thread:
http://discussion.autodesk.com/forums/thread.jspa?messageID=5792813
(I'm running Vista 64 Ultimate.)
I have tried running my activator method then using FinalReleaseCOMObject on the Application object, and then going File->Exit Inventor. But this won't work either.
{code}
Private Sub ReleaseApplicationCOMReference()
If m_objInventorApplication IsNot Nothing Then
System.Runtime.InteropServices.Marshal.FinalReleaseComObject(m_objInventorApplication)
m_objInventorApplication = Nothing
GC.Collect()
GC.WaitForPendingFinalizers()
GC.Collect()
End If
End Sub
{code}
Now, if I open Inventor first, then use GetObject / GetActiveObject to hook onto it, closing it inside Inventor will ends its process, irregardless of whether I release the COM object.
{code}
m_objInventorApplication = _
CType(System.Runtime.InteropServices.Marshal.GetActiveObject("Inventor.Application"), Inventor.Application)
{code}
Is this some sort of Inventor bug or is it COM related?
I use the following code to launch Inventor:
{code}
Dim t As Type = Type.GetTypeFromProgID("Inventor.Application")
m_objInventorApplication = CType(Activator.CreateInstance(t), Inventor.Application)
{code}
This starts Inventor just fine. The problem comes with closing it down. The process won't actually shut down if you go File-> Exit Inventor or click the X in the title bar. However, if I use my Application object, I can use .Quit and the process dies. Interestingly, I can also kill the process by invoking a different addin that I wrote that calls the .Quit function.
Telling Inventor itself to close will not end its process.
I believe this to be similar to the case in this thread:
http://discussion.autodesk.com/forums/thread.jspa?messageID=5792813
(I'm running Vista 64 Ultimate.)
I have tried running my activator method then using FinalReleaseCOMObject on the Application object, and then going File->Exit Inventor. But this won't work either.
{code}
Private Sub ReleaseApplicationCOMReference()
If m_objInventorApplication IsNot Nothing Then
System.Runtime.InteropServices.Marshal.FinalReleaseComObject(m_objInventorApplication)
m_objInventorApplication = Nothing
GC.Collect()
GC.WaitForPendingFinalizers()
GC.Collect()
End If
End Sub
{code}
Now, if I open Inventor first, then use GetObject / GetActiveObject to hook onto it, closing it inside Inventor will ends its process, irregardless of whether I release the COM object.
{code}
m_objInventorApplication = _
CType(System.Runtime.InteropServices.Marshal.GetActiveObject("Inventor.Application"), Inventor.Application)
{code}
Is this some sort of Inventor bug or is it COM related?