Solved

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

Posted on 2006-11-18
10
309 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
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
Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

 
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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Path of Workbook 3 78
python question 5 76
What is Python programming? 3 113
What does != "" mean in programming 8 34
Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
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…

778 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