tatamaruri
asked on
error UserControl when run app????? (vs.NET2005)
I created a UserControl in Windows form. I built the control successfully. but when I added that control to an app then I got this error:
-----------
One or more errors encountered while loading the designer. The errors are listed below. Some errors can be fixed by rebuilding your project, while others may require code changes.
Object reference not set to an instance of an object.
Hide
at System.ComponentModel.Refl ectPropert yDescripto r.SetValue (Object component, Object value)
at System.ComponentModel.Desi gn.Seriali zation.Cod eDomSerial izerBase.D eserialize AssignStat ement(IDes ignerSeria lizationMa nager manager, CodeAssignStatement statement)
at System.ComponentModel.Desi gn.Seriali zation.Cod eDomSerial izerBase.D eserialize Statement( IDesignerS erializati onManager manager, CodeStatement statement)
--------------
I found that if without this code in usercontrol my app had no problem:
---------------
<Category("Get Data"), DefaultValue("")> Public Property GetTable() As String
Get
Return Me._tableName
End Get
Set(ByVal value As String)
Dim a As String = ""
For Each name As DataTable In Me._data.Tables
If name.TableName.ToUpper() = value.ToUpper() Then
Me._tableName = value
Exit Property
End If
Next
Throw New ArgumentException("there is no this table")
End Set
End Property
-----------------
thanks in advance
-----------
One or more errors encountered while loading the designer. The errors are listed below. Some errors can be fixed by rebuilding your project, while others may require code changes.
Object reference not set to an instance of an object.
Hide
at System.ComponentModel.Refl
at System.ComponentModel.Desi
at System.ComponentModel.Desi
--------------
I found that if without this code in usercontrol my app had no problem:
---------------
<Category("Get Data"), DefaultValue("")> Public Property GetTable() As String
Get
Return Me._tableName
End Get
Set(ByVal value As String)
Dim a As String = ""
For Each name As DataTable In Me._data.Tables
If name.TableName.ToUpper() = value.ToUpper() Then
Me._tableName = value
Exit Property
End If
Next
Throw New ArgumentException("there is no this table")
End Set
End Property
-----------------
thanks in advance
That area of code is from:
#pragma region Windows Form Designer generated code
...
to
...
#pragma endregion
If you could post the code you have in between there, perhaps we can see what the problem is. =)
#pragma region Windows Form Designer generated code
...
to
...
#pragma endregion
If you could post the code you have in between there, perhaps we can see what the problem is. =)
I'm sorry I thought you were using C++...never mind what I wrote.
What happens if you don't use the attribute <Category("Get Data"), DefaultValue("")> ?
ASKER
still error :(
ASKER
Ah... I fixed it.
Because I had a condition "if" to get GetTable property. So when I had value in form but did not have in control class make it conflict.
Now I make some codes to remove that value in form and the error disappear.
Anyway... thanks all of you
Because I had a condition "if" to get GetTable property. So when I had value in form but did not have in control class make it conflict.
Now I make some codes to remove that value in form and the error disappear.
Anyway... thanks all of you
ASKER
I had another solution. I fix previous code to:
<Category("Get Data"), DefaultValue("")> Public Property GetTable() As String
Get
Return Me._tableName
End Get
Set(ByVal value As String)
If _data IsNot Nothing Then
For Each name As DataTable In Me._data.Tables
If name.TableName.ToUpper() = value.ToUpper() Then
Me._tableName = value
Exit Property
End If
Next
Throw New ArgumentException("there is no this table")
End If
End Set
End Property
<Category("Get Data"), DefaultValue("")> Public Property GetTable() As String
Get
Return Me._tableName
End Get
Set(ByVal value As String)
If _data IsNot Nothing Then
For Each name As DataTable In Me._data.Tables
If name.TableName.ToUpper() = value.ToUpper() Then
Me._tableName = value
Exit Property
End If
Next
Throw New ArgumentException("there is no this table")
End If
End Set
End Property
I think the error was because the data list had nothing in it and the code was trying to use a value from it.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
If you undo what you changed in there, the designer should work again.