Hello every one again...
I Hope you are not getting tired of me asking stupid questions...
I have a similar routine working in an old version of our office automation, and for this rewrite I am attempting to modify the custompropertybag object inside a listview (showdialog) form. I passed the custompropertybag as a variable to this form (as per my previous thread here), and am able to extract all the relevent names/values/flags to populate the listview. the user is able to modify the values in this listview (showdialog) form.
I am now trying to assign the values back to the custompropertybag and am getting this error message...
System.NullReferenceException: Object reference not set to an instance of an object. at ACSMCOMPONENTS18Lib.IAcSmCustomPropertyBag.SetProperty(String name, AcSmCustomPropertyValue value) at SSMExplorer.CustomPropertyEditorForm.SetCustomProperty(String Name, String Value, String Flag) in C:\Users\Adam Kalajzich\Documents\Visual Studio 2010\Projects\SSMExplorer\SSMExplorer\CustomPropertyEditorForm.vb:line 193 ...
and here is the code that I am using:
Private Function SetCustomProperty(ByVal Name As String, _ ByVal Value As String, _ ByVal Flag As String) As Boolean Dim myProp As New AcSmCustomPropertyValue myProp.SetValue(Value.ToString) Select Case Flag Case "EMPTY" If True Then myProp.SetFlags(PropertyFlags.EMPTY) End If Exit Select Case "CUSTOM_SHEETSET_PROP" If True Then myProp.SetFlags(PropertyFlags.CUSTOM_SHEETSET_PROP) End If Exit Select Case "CUSTOM_SHEET_PROP" If True Then myProp.SetFlags(PropertyFlags.CUSTOM_SHEET_PROP) End If Exit Select End Select CPB.SetProperty(Name, myProp) '' defined by Public/global variable CPB As AcSmCustomPropertyBag
'' errors on above line
End Function
So,
I have attempted to hunt down this issue, but regretably with no results.
my understanding is that the error message is saying I am attempting to reference an object that has a value ( or lack of a value) that is NOTHING. The use of "new" was also investigated.
so, while debuging, I have placed a few "if not nothing"s around the variables and all have values. I can interigate and watch the values being set and manipulated, in the debug / watch windows.
the command: CPB.SetProperty(name, myProp) does trigger the error message, but no variable is set to nothing
I have been able to extract information from the CPB object, why can I not write information to this object?
The only hint that I have is that I need to use:
myProp.initnew(someobject as IAcSMPersist)
but the above line only is used when choosing where (parent object) the custom propertybad is. I dont need (?) to do this, because I have the custompropertybag object itself.
I am at a loss, can any one point me or help me to the correct way to setproperty to a CPB object.