Solved

error UserControl when run app????? (vs.NET2005)

Posted on 2006-11-18
10
312 Views
Last Modified: 2010-05-18
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
Comment
Question by:tatamaruri
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
10 Comments
 
LVL 8

Expert Comment

by:YoungBonzi
ID: 17972068
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
 
LVL 8

Expert Comment

by:YoungBonzi
ID: 17972079
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
 
LVL 8

Expert Comment

by:YoungBonzi
ID: 17972132
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!

 
LVL 20

Expert Comment

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

0
 

Author Comment

by:tatamaruri
ID: 17975133
still error :(
0
 

Author Comment

by:tatamaruri
ID: 17975150
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
 

Author Comment

by:tatamaruri
ID: 17975217
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
 
LVL 5

Expert Comment

by:sivachirravuri
ID: 17978426
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
 
LVL 1

Accepted Solution

by:
DarthMod earned 0 total points
ID: 18357067
PAQed with points refunded (500)

DarthMod
Community Support Moderator
0

Featured Post

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!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question