473,395 Members | 1,341 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Error serializing derived Custom Collection Class

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
0 2465

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Craig Schneider | last post by:
// Can anyone explain the bizarre XML Serialization behavior seen in the following code. // It seems that a collection can not be XML Serialized if it contains an Add() method // with a single...
2
by: Aleksei Guzev | last post by:
Imagine one writing a class library CL1 for data storage. He defines classes ‘DataItem’ and ‘DataRecord’ so that the latter contains a collection of the former. And he derives class ‘IntItem’ from...
2
by: Phillip Galey | last post by:
I have an object called Place which contains only string properties and has the <Serializable()> flag before the class name declaration. I also have a collection object called Places, which is...
0
by: Jordan Bowness | last post by:
I make a similar post in another newsgroup, but this example is simplified somewhat. I have a component (cmpMyComponent) with 2 properties. The 1st property is a string value (Description) and...
3
by: RandomEngineer | last post by:
So here's the challenge... How can a collection (System.Collections.Generic.IList) of some custom type be serialized in a web service using .NET 2.0? Below are the class and the web methods in...
26
by: nyathancha | last post by:
Hi, How Do I create an instance of a derived class from an instance of a base class, essentially wrapping up an existing base class with some additional functionality. The reason I need this is...
5
by: Nirdesh | last post by:
Hi, I am serializing a custom class holding some data for my project. This data internally contains a class which contains an event public delegate void MemberModifiedEventHandler(object...
0
by: Shaul | last post by:
Hi, My goal is to serialize a collection of type IList<AbstractClass> which contains derived objects instances. My domain object model is a bit complex so I've created a demmi one: public...
1
by: Karthik1979 | last post by:
I have a custom class inherited from List<T> collection. Along with the base class functionality, I have included my additional properties. When serializing, only the base class items are serialized...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.