[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Li Chen

1/23/2003 11:04:00 PM

I got an error at the following line:

XmlSerializer x = new XmlSerializer(typeof(Databases),new
XmlRootAttribute("Databases"));

The error message is:

An unhandled exception of
type 'System.IO.FileNotFoundException' occurred in
mscorlib.dll

Additional information: File or assembly name
<randomize>.dll, or one of its dependencies, was not found.

This error message has been posted a few times on this
group but there was no solution. Now I have new
informations.

The following is the definition of Database class:

public class Databases: ICollection
{
private SortedList _databases = new SortedList();

public Database this[int index]
{
get{return (Database) _databases.GetByIndex
(index);}
}

public Database this[string dbname]
{
get{return (Database) _databases[dbname];}
}

public bool Contains(string key)
{
return _databases.ContainsKey(key);
}

public void CopyTo(Array a, int index)
{
_databases.CopyTo(a, index);
}

public int Count
{
get{return _databases.Count;}
}

public object SyncRoot
{
get{return this;}
}

public bool IsSynchronized
{
get{return false;}
}

public IEnumerator GetEnumerator()
{
return _databases.GetEnumerator();
}

public void Add(Database db)
{
_databases.Add(db.Name, db);
}
}

If I have members of ICollection interface coded as:

public void CopyTo(Array a, int index)

no errors occured.

If I have members of ICollection interface coded as:

void ICollection.CopyTo(Array a, int index)

the above error would occur.

What difference does it make when I implement the
IColletion implicitely or explicitely?

Li Chen
3 Answers

(Xin Tian[MSFT])

1/24/2003 11:50:00 AM

0

Hi Li,

Could also post your database class file, i did test with a simple database
class, with both following declarations, no exception get thrown,
void ICollection.CopyTo(Array a, int index)
public void CopyTo(Array a, int index)

Best regards,
xintian
VS.NET, Visual C++
Microsoft

This posting is provided "AS IS" with no warranties, and confers no rights.
Got .Net? http://www.got...

Christoph Schittko

1/24/2003 3:33:00 PM

0

is this code executed from within a strong named assembly, such as a
ServicedComponent registered with COM+?

--
Christoph Schittko
Software Architect


"Li Chen" <lichen@linkline.com> wrote in message
news:021001c2c32b$5e420430$d7f82ecf@TK2MSFTNGXA14...
> I got an error at the following line:
>
> XmlSerializer x = new XmlSerializer(typeof(Databases),new
> XmlRootAttribute("Databases"));
>
> The error message is:
>
> An unhandled exception of
> type 'System.IO.FileNotFoundException' occurred in
> mscorlib.dll
>
> Additional information: File or assembly name
> <randomize>.dll, or one of its dependencies, was not found.
>
> This error message has been posted a few times on this
> group but there was no solution. Now I have new
> informations.
>
> The following is the definition of Database class:
>
> public class Databases: ICollection
> {
> private SortedList _databases = new SortedList();
>
> public Database this[int index]
> {
> get{return (Database) _databases.GetByIndex
> (index);}
> }
>
> public Database this[string dbname]
> {
> get{return (Database) _databases[dbname];}
> }
>
> public bool Contains(string key)
> {
> return _databases.ContainsKey(key);
> }
>
> public void CopyTo(Array a, int index)
> {
> _databases.CopyTo(a, index);
> }
>
> public int Count
> {
> get{return _databases.Count;}
> }
>
> public object SyncRoot
> {
> get{return this;}
> }
>
> public bool IsSynchronized
> {
> get{return false;}
> }
>
> public IEnumerator GetEnumerator()
> {
> return _databases.GetEnumerator();
> }
>
> public void Add(Database db)
> {
> _databases.Add(db.Name, db);
> }
> }
>
> If I have members of ICollection interface coded as:
>
> public void CopyTo(Array a, int index)
>
> no errors occured.
>
> If I have members of ICollection interface coded as:
>
> void ICollection.CopyTo(Array a, int index)
>
> the above error would occur.
>
> What difference does it make when I implement the
> IColletion implicitely or explicitely?
>
> Li Chen


Li Chen

1/24/2003 7:01:00 PM

0

No. The code is not executed from within a strong named assembly.

When I use the C# to VB converter to convert the code to VB.NET, VB.NET does
not throw exception even when I implement the interface explicitly. Checked
under ISDASM, the compiled code from VB.NET explicit interface
implementation is same as C# implicit interface implementation, but the
compiled code from C# explicit interface implementation looks different.

Li

"Christoph Schittko" <ChristophDotNetINVALID@austin.rr.com> wrote in message
news:#$W1QV7wCHA.2372@TK2MSFTNGP12...
> is this code executed from within a strong named assembly, such as a
> ServicedComponent registered with COM+?
>
> --
> Christoph Schittko
> Software Architect
>
>
> "Li Chen" <lichen@linkline.com> wrote in message
> news:021001c2c32b$5e420430$d7f82ecf@TK2MSFTNGXA14...
> > I got an error at the following line:
> >
> > XmlSerializer x = new XmlSerializer(typeof(Databases),new
> > XmlRootAttribute("Databases"));
> >
> > The error message is:
> >
> > An unhandled exception of
> > type 'System.IO.FileNotFoundException' occurred in
> > mscorlib.dll
> >
> > Additional information: File or assembly name
> > <randomize>.dll, or one of its dependencies, was not found.
> >
> > This error message has been posted a few times on this
> > group but there was no solution. Now I have new
> > informations.
> >
> > The following is the definition of Database class:
> >
> > public class Databases: ICollection
> > {
> > private SortedList _databases = new SortedList();
> >
> > public Database this[int index]
> > {
> > get{return (Database) _databases.GetByIndex
> > (index);}
> > }
> >
> > public Database this[string dbname]
> > {
> > get{return (Database) _databases[dbname];}
> > }
> >
> > public bool Contains(string key)
> > {
> > return _databases.ContainsKey(key);
> > }
> >
> > public void CopyTo(Array a, int index)
> > {
> > _databases.CopyTo(a, index);
> > }
> >
> > public int Count
> > {
> > get{return _databases.Count;}
> > }
> >
> > public object SyncRoot
> > {
> > get{return this;}
> > }
> >
> > public bool IsSynchronized
> > {
> > get{return false;}
> > }
> >
> > public IEnumerator GetEnumerator()
> > {
> > return _databases.GetEnumerator();
> > }
> >
> > public void Add(Database db)
> > {
> > _databases.Add(db.Name, db);
> > }
> > }
> >
> > If I have members of ICollection interface coded as:
> >
> > public void CopyTo(Array a, int index)
> >
> > no errors occured.
> >
> > If I have members of ICollection interface coded as:
> >
> > void ICollection.CopyTo(Array a, int index)
> >
> > the above error would occur.
> >
> > What difference does it make when I implement the
> > IColletion implicitely or explicitely?
> >
> > Li Chen
>
>