> I have implemented a class that contains two Serial port objects among other
> things. When I try to serialize this class I get an error relating to the
[quoted text clipped - 3 lines]
>
> Any help is greatly appreciated.
look at [Serializable] attribute
to make clas serializable
[Serializable]
public class YourClass
{
}
}{ - 02 Apr 2008 18:13 GMT
>> I have implemented a class that contains two Serial port objects among
>> other things. When I try to serialize this class I get an error relating
[quoted text clipped - 12 lines]
>
> }
I did this, but I think the error relates specifically to the fact that my
class contains other classes that aren't serializable. It is only a guess
though because I'm not too familiar with C#.
I will get out my laptop later and post some code and the error received if
it helps.
Thanks
Ignacio Machin ( .NET/ C# MVP ) - 02 Apr 2008 19:10 GMT
> >> I have implemented a class that contains two Serial port objects among
> >> other things. When I try to serialize this class I get an error relating
[quoted text clipped - 23 lines]
>
> - Show quoted text -
Use a [NonSerialized] attribute for those members
Ben Voigt [C++ MVP] - 02 Apr 2008 21:04 GMT
>>>> I have implemented a class that contains two Serial port objects
>>>> among other things. When I try to serialize this class I get an
[quoted text clipped - 26 lines]
>
> Use a [NonSerialized] attribute for those members
I think a custom serialization function is needed, to serialize port number
or whatever needs to be saved, but more importantly to reopen ports when
deserializing.
Ignacio Machin ( .NET/ C# MVP ) - 02 Apr 2008 22:46 GMT
> >> "gigs" <g...@hi.t-com.hr> wrote in message
>
[quoted text clipped - 36 lines]
>
> - Show quoted text -
Hi,
Yes, you are right, in the case that this info is not kept in others
properties or members.
Arne Vajhøj - 05 Apr 2008 20:04 GMT
>>>>>> I have implemented a class that contains two Serial port objects
>>>>>> among other things. When I try to serialize this class I get an
[quoted text clipped - 19 lines]
> Yes, you are right, in the case that this info is not kept in others
> properties or members.
I think the idea in itself are questionable.
There is a reason those fields are not serializable.
On computer A you serialize an instance that has COM1-COM2 and write it
over socket to computer B that has only COM1. What should the receiving
program do ?
Arne
Ignacio Machin ( .NET/ C# MVP ) - 02 Apr 2008 19:36 GMT
> > I have implemented a class that contains two Serial port objects among other
> > things. When I try to serialize this class I get an error relating to the
[quoted text clipped - 15 lines]
>
> - Show quoted text -
The OP problem is that some fields are not serializables, with the
NonSerializable atribute the problem should be solved.