Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / Web Services / November 2005

Tip: Looking for answers? Try searching our database.

Serialization of custom object?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
leodippolito@gmail.com - 18 Nov 2005 00:38 GMT
Dear sirs,

I am using custom wrappers to primitive types in my classes, so I can
have some flags when working with the database ("undefined" and "null")
.

So instead of:

[Serializable]
public class User
{
  private int _id;
  private string _name;

  public int Id
  { get {return this._id;} }

  public string Name
  { get {return this._name;} }
}

I have:

[Serializable]
public class User
{
  private MyIntWrapper _id;
  private MyStringWrapper _name;

  public MyIntWrapper Id
  { get {return this._id;} }

  public MyStringWrapper Name
  { get {return this._name;} }
}

In the wrapper objects I have a ".Value" attribute that sets/returns
the primitive type. If the wrapper is flagged as null or undefined it
THROWS AN EXCEPTION. That is a by-design behavior.

The problem is: even if I mark MyIntWrapper, MyStringWrapper and User
classes with [Serializable] attribute, I get an Exception when trying
to serialize an instance of User, because sometimes one of its
properties is undefined or null and therefore throws nd exception when
being accessed.

How can I solve this? Do I need a custom serialization and
de-serialization?

TIA,

Leo D'Ippolito
CG - 18 Nov 2005 01:52 GMT
You would need to write customer serialization to handle this situation.

> Dear sirs,
>
[quoted text clipped - 48 lines]
>
> Leo D'Ippolito

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.