Can't close the program

Can't close the program

Anonymous
Not applicable
366 Views
2 Replies
Message 1 of 3

Can't close the program

Anonymous
Not applicable
VB.net 2003 IV.11 sp3
Using apprentice to re-reference part files I can’t close the program.
I have a problem with the END command in my project form when the form closes.

It throws an exception, the following is the exception text.

An unhandled exception of type 'System.NullReferenceException' occurred in mscorlib.dll
Additional information: Object reference not set to an instance of an object.

When I catch the exception and try to open a message box this is the exception text.

An unhandled exception of type 'System.InvalidOperationException' occurred in mscorlib.dll
Additional information: LocalDataStoreSlot storage has been freed.

Below is the entire module, and the offending line is
oADoc = oApprentice.Open(sOldPartPath).

I can comment out all the lines of code after this line and the problem still exists.

Imports Inventor
Imports Microsoft.Win32

Module Apprentice
Public Sub ChangeReferenceWithApprentice(ByVal sOldPartPath As String, ByVal sOldReference As String, ByVal sNewPartPath As String, ByVal sNewReference As String

Dim oApprentice As New ApprenticeServerComponent
Dim oADoc As ApprenticeServerDocument

oADoc = oApprentice.Open(sOldPartPath)

Dim oRefFileDesc As ReferencedFileDescriptor
For Each oRefFileDesc In oADoc.ReferencedFileDescriptors
If UCase$(GetNewFileName(oRefFileDesc.FullFileName)) = UCase$(GetNewFileName(sOldReference)) Then
Try
oRefFileDesc.PutLogicalFileNameUsingFull(sNewReference) Catch ex As Exception
Debug.WriteLine("Exception Thrown ((Message)) " & ex.Message & " ((To String)) " & ex.ToString & " ((NewReference)) " & sNewReference)
End Try
End If
Next

Try
Call oApprentice.FileSaveAs.AddFileToSave(oADoc, sNewPartPath)
oApprentice.FileSaveAs.ExecuteSaveAs()
Catch ex As Exception
Debug.WriteLine("Exception Thrown ((Message)) " & ex.Message & " ((To String)) " & ex.ToString & " ((sNewPartPath)) " & sNewPartPath)
MsgBox("There is a problem with the Inventor files. They probably need to be migrated.")
End Try

oADoc = Nothing
oApprentice = Nothing
End Sub
End Module

I would appreciate any help with this issue.
0 Likes
367 Views
2 Replies
Replies (2)
Message 2 of 3

Anonymous
Not applicable
Could you try calling oApprentice.Close before setting the variables
oApprentice & oADoc to Nothing?

Sanjay-

wrote in message news:5644129@discussion.autodesk.com...
VB.net 2003 IV.11 sp3
Using apprentice to re-reference part files I can't close the program.
I have a problem with the END command in my project form when the form
closes.

It throws an exception, the following is the exception text.

An unhandled exception of type 'System.NullReferenceException' occurred in
mscorlib.dll
Additional information: Object reference not set to an instance of an
object.

When I catch the exception and try to open a message box this is the
exception text.

An unhandled exception of type 'System.InvalidOperationException' occurred
in mscorlib.dll
Additional information: LocalDataStoreSlot storage has been freed.

Below is the entire module, and the offending line is
oADoc = oApprentice.Open(sOldPartPath).

I can comment out all the lines of code after this line and the problem
still exists.

Imports Inventor
Imports Microsoft.Win32

Module Apprentice
Public Sub ChangeReferenceWithApprentice(ByVal sOldPartPath As String,
ByVal sOldReference As String, ByVal sNewPartPath As String, ByVal
sNewReference As String

Dim oApprentice As New ApprenticeServerComponent
Dim oADoc As ApprenticeServerDocument

oADoc = oApprentice.Open(sOldPartPath)

Dim oRefFileDesc As ReferencedFileDescriptor
For Each oRefFileDesc In oADoc.ReferencedFileDescriptors
If UCase$(GetNewFileName(oRefFileDesc.FullFileName)) =
UCase$(GetNewFileName(sOldReference)) Then
Try
oRefFileDesc.PutLogicalFileNameUsingFull(sNewReference)
Catch ex As Exception
Debug.WriteLine("Exception Thrown ((Message)) " &
ex.Message & " ((To String)) " & ex.ToString & " ((NewReference)) " &
sNewReference)
End Try
End If
Next

Try
Call oApprentice.FileSaveAs.AddFileToSave(oADoc, sNewPartPath)
oApprentice.FileSaveAs.ExecuteSaveAs()
Catch ex As Exception
Debug.WriteLine("Exception Thrown ((Message)) " & ex.Message & "
((To String)) " & ex.ToString & " ((sNewPartPath)) " & sNewPartPath)
MsgBox("There is a problem with the Inventor files. They
probably need to be migrated.")
End Try

oADoc = Nothing
oApprentice = Nothing
End Sub
End Module

I would appreciate any help with this issue.
0 Likes
Message 3 of 3

Anonymous
Not applicable
I have tried that but it makes no difference.

Malcolm
0 Likes