Daniel Wilson
asked on
Code generation for property <propertyname> failed: Property accessor on object threw ... Object reference not set ...
I have added a property to a user control. At runtime, it functions flawlessly. At design time, however, I am repeatedly interrupted by the error:
Code generation for property 'HideAddins' failed. Errors was: 'property accessor 'Hideaddins' on object <mycontrol> threw the following exception: 'Object reference on set to an instance of an object.''
I have code in which should absolutely prevent an 'Object reference not set' condition. I also have code which should trap it, should it somehow occur. I also have attributes in place to try to get the property left alone at design time. All to no avail.
What am I doing wrong?
Thanks!
Code generation for property 'HideAddins' failed. Errors was: 'property accessor 'Hideaddins' on object <mycontrol> threw the following exception: 'Object reference on set to an instance of an object.''
I have code in which should absolutely prevent an 'Object reference not set' condition. I also have code which should trap it, should it somehow occur. I also have attributes in place to try to get the property left alone at design time. All to no avail.
What am I doing wrong?
Thanks!
<Browsable(False)> _
<DefaultValue(False)> _
Public Property HideAddins() As Boolean
Get
Try
If Not tcNotes Is Nothing AndAlso Not tcNotes.TabPages Is Nothing Then
Return Not tcNotes.TabPages.ContainsKey("tpAddIns")
Else
Return False
End If
Catch
Return False
End Try
End Get
Set(ByVal value As Boolean)
Try
If Not tcNotes Is Nothing AndAlso Not tcNotes.TabPages Is Nothing Then
If value Then
'tcNotes.TabPages("tpAddIns").Hide() '.IsAccessible = Not value
If tcNotes.TabPages.ContainsKey("tpAddIns") Then tcNotes.TabPages.RemoveByKey("tpAddIns")
Else
'tcNotes.TabPages("tpAddIns").Show()
If Not tcNotes.TabPages.ContainsKey("tpAddIns") Then tcNotes.TabPages.Add(tpAddIns)
End If
End If
Catch
End Try
End Set
End Property
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Yes, after thoroughly getting rid of cached junk & restarting Visual Studio, it worked!
ASKER
Thanks! I never would have suspected that one as being my problem!
NP. Glad to help :)
ASKER
Working to see if something may be cached ...