Message 1 of 3
Can't close the program

Not applicable
06-30-2007
04:00 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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.
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.