Solved

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

Posted on 2006-11-18
10
299 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
Comment Utility
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
Comment Utility
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
Comment Utility
I'm sorry I thought you were using C++...never mind what I wrote.
0
 
LVL 19

Expert Comment

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

0
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 

Author Comment

by:tatamaruri
Comment Utility
still error :(
0
 

Author Comment

by:tatamaruri
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
PAQed with points refunded (500)

DarthMod
Community Support Moderator
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
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…

762 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now