I’m trying to keep Visual Studio from attempting to serialize the datasource of drop down list. It’s just a simple control that loads its datasource from the database, and inherits from ComboBox. My objects I use for the datasoure are not serializable so it errors when I trying to do almost anything the designer, saying code generation has failed. I’ve tried adding this to my code hoping that it would stop VS from doing this but it hasn’t worked.
<Obsolete("This property does nothing.")>
<System.ComponentModel.Browsable(False)> _
<System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)> _
Public Shadows Property Datasource() As Object
Get
Return Nothing
End Get
Set(ByVal value As Object)
End Set
End Property
It still somehow is accessing datasource, so it must be seeing my control as a ComboBox and reading the base class property. Is there anything I can do to stop it?
Not exactly what I was thinking, but I guess it does answer the question, as I am OK with the control not being bound to a datasource during design time, but using this property,
From this article: http://dotnetfacts.blogspot.com/2009/01/identifying-run-time-and-design-mode.html
I can prevent myself from loading the datasource during design time, so VS has nothing to attempt to serialize.