Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 317
  • Last Modified:

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.ReflectPropertyDescriptor.SetValue(Object component, Object value)
at System.ComponentModel.Design.Serialization.CodeDomSerializerBase.DeserializeAssignStatement(IDesignerSerializationManager manager, CodeAssignStatement statement)
at System.ComponentModel.Design.Serialization.CodeDomSerializerBase.DeserializeStatement(IDesignerSerializationManager 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
0
tatamaruri
Asked:
tatamaruri
1 Solution
 
YoungBonziCommented:
There's an area that you're not supposed to modify if you want to use the designer...it should be pre-commented.

If you undo what you changed in there, the designer should work again.
0
 
YoungBonziCommented:
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. =)
0
 
YoungBonziCommented:
I'm sorry I thought you were using C++...never mind what I wrote.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
Daniel Van Der WerkenCommented:
What happens if you don't use the attribute <Category("Get Data"), DefaultValue("")> ?

0
 
tatamaruriAuthor Commented:
still error :(
0
 
tatamaruriAuthor Commented:
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
0
 
tatamaruriAuthor Commented:
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
0
 
sivachirravuriCommented:
I think the error was because the data list had nothing in it and the code was trying to use a value from it.
0
 
DarthModCommented:
PAQed with points refunded (500)

DarthMod
Community Support Moderator
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now