By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,223 Members | 1,403 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,223 IT Pros & Developers. It's quick & easy.

Error serializing derived Custom Collection Class

P: n/a
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.
Nov 12 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.