views:

235

answers:

3

Hi all,

I though I had solved this problem, but it is back:

Code generation for property 'SelectedPeople' failed. Error was: 'Type 'ECS.Entities.Persistency.Person' in Assembly 'ECS, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' is not marked as serializable.'

The property on the error message is a List(Of Person) and for some reason it trigger this error, for almost anything I do, and its getting really anoying.

Ok answering to the answers here is a little more information about the problem.

Yes it is during design time, it happens bascially anytime a open a form that has a UserControl that contains the Selected property in it, sometimes it happens even if I don't have focus on the form, also if I try to compile/run it happens and the message come in the form of a Message Box with just a OK, ECS.Entities.Persistency.Person is just a LINQ to SQL Generated Class, this should not matter at all to the problem, although I have added the attribute before the posting.

The reason that this happens is because the Designer attempts to put the property on the Property Panel, and for that to happen, serialization happens. To help on that I tryed to hide the property from the designer by using this attributes.

<DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)> _
    <Browsable(False)> _
    Public Property SelectedPeople() As List(Of Person)
        Get
            Return _SelectedPeople
        End Get
        Set(ByVal value As List(Of Person))
            _SelectedPeople = value
        End Set
    End Property

This was working before but for some unkown reason it started again.

If you all know anything about getting this fixed I would apreciate.

Thanks

+1  A: 

It sounds like you need to add the Serializable attribute to ECS.Entities.Persistency.Person.

It would look something like this:

<Serializable()> _
Class Person
    'Class definition here
End Class
Joseph
+1  A: 

The designer doesn't always seem to give accurate error messages. When the designer throws an error like this, it's often best to see what exactly you most recently changed on the control. It's entirely likely that it has nothing to do with the stated error message.

Also, the designer sometimes gets into a bad state and throws error messages. Sometimes, restarting and rebuilding clears things up.

NascarEd
I think this solved the problem since I am not having it anymore, I did this before you posted, there might be a caching problem ( Had this before, in other situations).So thanks.
Oakcool
A: 

In case anyone else runs into this same problem and can't get it to work even after rebuilding the project, I fixed it after replacing this missing line in the InitializeComponent() method in the Form1.Designer.cs:

System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1));