System.NullReferenceException - AskIdSymbolInfo - NX4 VB.NET App
System.NullReferenceException - AskIdSymbolInfo - NX4 VB.NET App
(OP)
Hi everyone,
I am currently developing a function which counts the number of all round ID symbols containing specific text. Since the NX4 NX/Open VB.NET API does not contain an IDSymbol object, I am using the UG/Open wrapper functions instead:
When running the program, it terminates with a System.NullReferenceException when trying to call AskIdSymbolInfo. Here is the snippet from the log file:
System.NullReferenceException: Object reference not set to an instance of an object.
at NXOpen.UF.UFDrf.AskIdSymbolInfo(Tag id_symbol_tag, IdSymbolType& id_symbol_type, Double[] id_symbol_origin, IdSymbolInfo[]& id_symbol_info)
at TDF_MIKRON_change_table.ChangeTable.CountIDSymbols(Part workPart, String idText)
at TDF_MIKRON_change_table.EntryPoint.Main()
*** EXCEPTION: Error code 67 in line 996 of O:\ugnx404\ip2\src\syss\no\ind\lmldr.c at Tue Dec 07 21:34:33 2010 W. Europe Standard Time
+++ Object reference not set to an instance of an object.
I'm not sure where the problem is, but my hunch is it has something to do with the variable declaration:
I'm really at a loss here and any help is much appreciated. Thanks!
I am currently developing a function which counts the number of all round ID symbols containing specific text. Since the NX4 NX/Open VB.NET API does not contain an IDSymbol object, I am using the UG/Open wrapper functions instead:
CODE
Dim idSymbolType As UFDrf.IdSymbolType
Dim idSymbolOrigin() As Double = {0.0, 0.0, 0.0}
Dim idSymbolInfo() As UFDrf.IdSymbolInfo
ufSession.Drf.AskIdSymbolInfo(idSymbolTag, idSymbolType, idSymbolOrigin, idSymbolInfo)
Dim idSymbolOrigin() As Double = {0.0, 0.0, 0.0}
Dim idSymbolInfo() As UFDrf.IdSymbolInfo
ufSession.Drf.AskIdSymbolInfo(idSymbolTag, idSymbolType, idSymbolOrigin, idSymbolInfo)
When running the program, it terminates with a System.NullReferenceException when trying to call AskIdSymbolInfo. Here is the snippet from the log file:
System.NullReferenceException: Object reference not set to an instance of an object.
at NXOpen.UF.UFDrf.AskIdSymbolInfo(Tag id_symbol_tag, IdSymbolType& id_symbol_type, Double[] id_symbol_origin, IdSymbolInfo[]& id_symbol_info)
at TDF_MIKRON_change_table.ChangeTable.CountIDSymbols(Part workPart, String idText)
at TDF_MIKRON_change_table.EntryPoint.Main()
*** EXCEPTION: Error code 67 in line 996 of O:\ugnx404\ip2\src\syss\no\ind\lmldr.c at Tue Dec 07 21:34:33 2010 W. Europe Standard Time
+++ Object reference not set to an instance of an object.
I'm not sure where the problem is, but my hunch is it has something to do with the variable declaration:
CODE
Dim idSymbolInfo() As UFDrf.IdSymbolInfo
I'm really at a loss here and any help is much appreciated. Thanks!





RE: System.NullReferenceException - AskIdSymbolInfo - NX4 VB.NET App
RE: System.NullReferenceException - AskIdSymbolInfo - NX4 VB.NET App
Here is the function:
CODE
CountIDSymbols = 0
Dim idSymbolTag As Tag = Tag.Null
Dim objType, objSubtype As Integer
Do
ufSession.Obj.CycleObjsInPart(workPart.Tag, UFConstants.UF_drafting_entity_type, idSymbolTag)
If Not idSymbolTag.Equals(Tag.Null) Then
ufSession.Obj.AskTypeAndSubtype(idSymbolTag, objType, objSubtype)
If objSubtype.Equals(UFConstants.UF_draft_id_symbol_subtype) Then
Dim idSymbolType As UFDrf.IdSymbolType
Dim idSymbolOrigin() As Double = {0.0, 0.0, 0.0}
Dim idSymbolInfo() As UFDrf.IdSymbolInfo
ufSession.Drf.AskIdSymbolInfo(idSymbolTag, idSymbolType, idSymbolOrigin, idSymbolInfo)
End If
End If
Loop Until idSymbolTag.Equals(Tag.Null)
End Function
RE: System.NullReferenceException - AskIdSymbolInfo - NX4 VB.NET App
Marc
NX Software Developer
RE: System.NullReferenceException - AskIdSymbolInfo - NX4 VB.NET App
Previously, I had NX 4.0.4.2.
I've updated to NX 4.0.4.2 MP10, but now I have a new error message (see below). Apparently, the NX/Open library of NX4 cannot be trusted at all! Has anyone here encountered such an error? Is there a work around for this? I don't want to start my program all over just so I can get it working in C... :/
Caught exception while running: Main
System.ArgumentException: Type _LeaderInfo can not be marshaled as an unmanaged structure; no meaningful size or offset can be computed.
at System.Runtime.InteropServices.Marshal.SizeOf(Type t)
at NXOpen.UF.UFDrf.AskIdSymbolInfo(Tag id_symbol_tag, IdSymbolType& id_symbol_type, Double[] id_symbol_origin, IdSymbolInfo[]& id_symbol_info)
at TDF_MIKRON_change_table.ChangeTable.CountIDSymbols(Part workPart, String idText)
at TDF_MIKRON_change_table.EntryPoint.Main()
*** EXCEPTION: Error code 67 in line 996 of F:\workdir\reference\NX404_2\src\syss\no\ind\lmldr.c at Fri Dec 10 00:55:05 2010 W. Europe Standard Time
+++ Type _LeaderInfo can not be marshaled as an unmanaged structure; no meaningful size or offset can be computed.
[ 1] 75C99617 (KERNELBASE)
Thanks!
Marc
NX Software Developer