HighTechTalks DotNet Forums  

Error serializing derived Custom Collection Class

Dotnet XML microsoft.public.dotnet.xml


Discuss Error serializing derived Custom Collection Class in the Dotnet XML forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
AT
 
Posts: n/a

Default Error serializing derived Custom Collection Class - 04-08-2004 , 11:44 PM






I am receiving an error stating that File or Assembly name
<filname.dll>, or one of its dependencies, was not found

In one assembly I have three abstract classes

In another I have three derived classes from the abstract classes

The 1st class contains the 2nd class
The 2nd class is a custom collection for the 3rd class

when I serialize the 1st class I am receiving the error. The classes
look like the following:

Abstract classes:



using System;
using System.Xml.Serialization;

namespace AbstractClasses
{
public abstract class ContainerBase
{
private LocationsCollectionBase _locations = null;
public ContainerBase()
{
}

[XmlIgnore()]
public virtual LocationsCollectionBase Locations
{
get
{
return this._locations;
}
set
{
this._locations = value;
}
}
}
}


using System;
using System.Xml.Serialization;

namespace AbstractClasses
{
public class LocationBase
{
public LocationBase()
{
}
}
}


using System;
using System.Collections;
using System.Xml.Serialization;

namespace AbstractClasses
{
public abstract class LocationsCollectionBase : ICollection
{
private ArrayList _locationsCollection;

public LocationsCollectionBase()
{
this._locationsCollection = new ArrayList();
}

public virtual int Add ( LocationBase Location)
{
return this._locationsCollection.Add (Location);
}

[XmlIgnore()]
public virtual LocationBase this [int i]
{
get
{
return (LocationBase)this._locationsCollection[i];
}
set
{
this._locationsCollection[i] = value;
}
}

#region ICollection Members


[XmlIgnore()]
public virtual bool IsSynchronized
{
get
{
return this._locationsCollection.IsSynchronized;
}
}

[XmlIgnore()]
public virtual int Count
{
get
{
return this._locationsCollection.Count;
}
}

public virtual void CopyTo(Array array, int index)
{
this._locationsCollection.CopyTo(array,index);
}

[XmlIgnore()]
public virtual object SyncRoot
{
get
{
return this._locationsCollection.SyncRoot;
}
}

#endregion

#region IEnumerable Members

public virtual IEnumerator GetEnumerator()
{
// TODO: Add LocationsCollectionBase.GetEnumerator implementation
return null;
}

#endregion
}
}


Derived classes:

using System;

namespace DerivedClasses
{
public class Container : AbstractClasses.ContainerBase
{
public Container()
{
base.Locations = new LocationsCollection();
}

public override AbstractClasses.LocationsCollectionBase Locations
{
get
{
return base.Locations;
}
set
{
base.Locations = value;
}
}

}
}


using System;

namespace DerivedClasses
{
public class Location : AbstractClasses.LocationBase
{
public Location()
{
}

public virtual string LocationName
{
get
{
//return base.LocationName;
return "Location: " + DateTime.Now.ToString();
}
}
}
}



The code to serialize looks like:

StreamWriter writer = new
StreamWriter(@"C:\windows\temp\serializetest\Conta iner1.xml");
DerivedClasses.Container Container1 = new DerivedClasses.Container();
XmlSerializer serializer1 = new
XmlSerializer(typeof(DerivedClasses.Container));
serializer1.Serialize(writer.BaseStream,Container1 );


Does anybody know what is wrong?

thanks,
-a.n.

Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.