473,385 Members | 1,642 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,385 software developers and data experts.

XmlSerializer, System.IO.FileNotFoundException

Hello,

I am attempting to have a class that I have written serialize so that it can
be both passed as a parameter or return value for a webservice, and also be
serialized to disk using the XmlSerializer.

When this class is decalred as a return value for a WebMethod in an XML
WebService I receive the following exception:

System.IO.FileNotFoundException: File or assembly name rexz5r1o.dll, or one
of its dependencies, was not found.
File name: "rexz5r1o.dll"....

I searched the newgroups for other people that experienced this problem and
found there to be many - with most of the fixes pointing towards permission
problems on the temporary folder that the framework writes temporary
assemblies to. I followed the advice given in these posts and gave the user
account my web service is running under full permission to the folder that
was shown in the error log. This did not solve the issue, and I was still
receiving the same error message as before.

This got me thinking, so I attempted to serialize this same class in a
simple console application that I can be 100% sure has basically full local
administrator permissions. I wrote a small application that utilized the
XmlSerializer class and got it successfully to serialize a basic class that
I wrote (not the class mentioned above) that only has a single string
property. I then changed the code to use the class that I wanted to
serialize in the first place thinking it would work - but with no luck. I
received the same error message.

I then decided to mimic my temporary class to look like the real class that
I wanted to have serialized and through trial and error have found the
exception is being caused by an explicit operator on my class that accepts a
strongly-typed DataRow as a parameter (it also occurs on a basic
System.Data.DataRow class). The exact class that causes this error can be
seen below:

[Serializable]
public class TestClass
{
private string testvalue;

public string TestValue
{
get { return testvalue; }
set { testvalue = value; }
}

public void SetTestValue(string newtestvalue)
{
testvalue = newtestvalue;
}

public static explicit operator TestClass(System.Data.DataRow row)
{
TestClass newclass = new TestClass();
newclass.name = row[0].ToString();

return newclass;
}
}

If you change the parameter type of the explicit operator to a normal string
type then the exception dissapears.

Just for some background, the class that this is happening on is an 'entity'
that maps a row from a table in a database, which is the reason why I have
written an explicit operator to 'map' a DataRow into a corresponding entity.

Has anyone else come across this issue before? I have searched high and low
and not yet found anyone that is experiencing this exact problem.

Any insight or help would be greatly appreciated.

Kind regards,

Chris Aitchison
senior developer
Protelligent, Inc.

PS. The source code that I am using to actually perform the serialization is
as follows:

FileStream fs = new FileStream("DataFile.dat", FileMode.Create);

try

{

// Construct a BinaryFormatter and use it

// to serialize the data to the stream.

XmlSerializer formatter = new XmlSerializer(typeof(TestBase[]));

//BinaryFormatter formatter = new BinaryFormatter();

// Create an array with multiple elements

TestBase[] a1 = { new TestBase(), new TestBase() };

a1[0].Name = "Hello";

a1[1].Name = "There";

//a1[0].City = "Hello";

//a1[1].City = "There";

// Serialize the array elements.

formatter.Serialize(fs, a1);

// Deserialize the array elements.

fs.Position = 0;

TestBase[] a2 = (TestBase[]) formatter.Deserialize(fs);

}

catch (SerializationException e)

{

Console.WriteLine("Failed to serialize. Reason: " + e.Message);

throw;

}

finally

{

fs.Close();

}
Nov 11 '05 #1
2 6776
Thankyou, that did tell me the exact exception that was happening behind the
scenes.

Perhaps someone might now be able to give me a hand in fixing the underlying
exception:

The type 'System.Data.DataRow' is defined in an assembly that is not
referenced.

I have a reference to this assembly, and the corresponding using statement -
but I guess the temporary assembly that the XmlSerializer creates is where
the assembly needs to be referenced. How do I reference it to stop this
error?

many thanks, and thankyou Daniel for you help in getting me this far!

Chris Aitchison
"Daniel Cazzulino" <ya****@nospam.siderar.com> wrote in message
news:u#**************@tk2msftngp13.phx.gbl...
There's a tiny useful utility to diagnose your problem, from Chris Sells:
http://sellsbrothers.com/tools/#XmlS...zerPreCompiler

--
../d:cazz
Daniel Cazzulino
DEVerest - Lagash
Tel +54 (0) 11 4247 7396
www.deverest.com.ar
www.lagash.com
dotnetopensrc.sourceforge.net

Coauthor of:
Beginning C# Web Applications with Visual Studio .NET
Beginning Web Programming using VB.NET and Visual Studio .NET
Professional ASP.NET Server Controls: Building Custom Controls with C#
ASP.NET Components Toolkit

"He who is good for making excuses, is seldom good for anything else."

"Chris Aitchison" <ch*************@hotmail.com> wrote in message
news:O9*************@TK2MSFTNGP11.phx.gbl...
Hello,

I am attempting to have a class that I have written serialize so that it can
be both passed as a parameter or return value for a webservice, and also

be
serialized to disk using the XmlSerializer.

When this class is decalred as a return value for a WebMethod in an XML
WebService I receive the following exception:

System.IO.FileNotFoundException: File or assembly name rexz5r1o.dll, or

one
of its dependencies, was not found.
File name: "rexz5r1o.dll"....

I searched the newgroups for other people that experienced this problem

and
found there to be many - with most of the fixes pointing towards

permission
problems on the temporary folder that the framework writes temporary
assemblies to. I followed the advice given in these posts and gave the

user
account my web service is running under full permission to the folder that was shown in the error log. This did not solve the issue, and I was still receiving the same error message as before.

This got me thinking, so I attempted to serialize this same class in a
simple console application that I can be 100% sure has basically full

local
administrator permissions. I wrote a small application that utilized the XmlSerializer class and got it successfully to serialize a basic class

that
I wrote (not the class mentioned above) that only has a single string
property. I then changed the code to use the class that I wanted to
serialize in the first place thinking it would work - but with no luck. I received the same error message.

I then decided to mimic my temporary class to look like the real class

that
I wanted to have serialized and through trial and error have found the
exception is being caused by an explicit operator on my class that accepts a
strongly-typed DataRow as a parameter (it also occurs on a basic
System.Data.DataRow class). The exact class that causes this error can
be seen below:

[Serializable]
public class TestClass
{
private string testvalue;

public string TestValue
{
get { return testvalue; }
set { testvalue = value; }
}

public void SetTestValue(string newtestvalue)
{
testvalue = newtestvalue;
}

public static explicit operator TestClass(System.Data.DataRow row)
{
TestClass newclass = new TestClass();
newclass.name = row[0].ToString();

return newclass;
}
}

If you change the parameter type of the explicit operator to a normal

string
type then the exception dissapears.

Just for some background, the class that this is happening on is an

'entity'
that maps a row from a table in a database, which is the reason why I have written an explicit operator to 'map' a DataRow into a corresponding

entity.

Has anyone else come across this issue before? I have searched high and

low
and not yet found anyone that is experiencing this exact problem.

Any insight or help would be greatly appreciated.

Kind regards,

Chris Aitchison
senior developer
Protelligent, Inc.

PS. The source code that I am using to actually perform the

serialization is
as follows:

FileStream fs = new FileStream("DataFile.dat", FileMode.Create);

try

{

// Construct a BinaryFormatter and use it

// to serialize the data to the stream.

XmlSerializer formatter = new XmlSerializer(typeof(TestBase[]));

//BinaryFormatter formatter = new BinaryFormatter();

// Create an array with multiple elements

TestBase[] a1 = { new TestBase(), new TestBase() };

a1[0].Name = "Hello";

a1[1].Name = "There";

//a1[0].City = "Hello";

//a1[1].City = "There";

// Serialize the array elements.

formatter.Serialize(fs, a1);

// Deserialize the array elements.

fs.Position = 0;

TestBase[] a2 = (TestBase[]) formatter.Deserialize(fs);

}

catch (SerializationException e)

{

Console.WriteLine("Failed to serialize. Reason: " + e.Message);

throw;

}

finally

{

fs.Close();

}


Nov 11 '05 #2
This cryptic error message that you are encountering occurs when the
XmlSerializer fails to serialize the type, because the type is too complex.
[ It can also occur when there are permissions problems, but that is
generally a red herring, and specifically in your case, it was certainly a
red herring!] Most often I have seen this occur on types that embed
members that are so-called "jagged" 2-D arrays, eg

public SomeType[][] SomeMember;
Can we see the type? Do you have a jagged array?

As you yourself saw, simplifying the type to be serialized can avoid the
problem. The other workaround *may be* to apply attributes to the offending
member to help the serializer understand what to do. Which of these is
preferred depends on your situation.

-Dino

"Chris Aitchison" <ch*************@hotmail.com> wrote in message
news:eV**************@TK2MSFTNGP10.phx.gbl...
Thankyou, that did tell me the exact exception that was happening behind the scenes.

Perhaps someone might now be able to give me a hand in fixing the underlying exception:

The type 'System.Data.DataRow' is defined in an assembly that is not
referenced.

I have a reference to this assembly, and the corresponding using statement - but I guess the temporary assembly that the XmlSerializer creates is where
the assembly needs to be referenced. How do I reference it to stop this
error?

many thanks, and thankyou Daniel for you help in getting me this far!

Chris Aitchison
"Daniel Cazzulino" <ya****@nospam.siderar.com> wrote in message
news:u#**************@tk2msftngp13.phx.gbl...
There's a tiny useful utility to diagnose your problem, from Chris Sells:
http://sellsbrothers.com/tools/#XmlS...zerPreCompiler

--
../d:cazz
Daniel Cazzulino
DEVerest - Lagash
Tel +54 (0) 11 4247 7396
www.deverest.com.ar
www.lagash.com
dotnetopensrc.sourceforge.net

Coauthor of:
Beginning C# Web Applications with Visual Studio .NET
Beginning Web Programming using VB.NET and Visual Studio .NET
Professional ASP.NET Server Controls: Building Custom Controls with C#
ASP.NET Components Toolkit

"He who is good for making excuses, is seldom good for anything else."

"Chris Aitchison" <ch*************@hotmail.com> wrote in message
news:O9*************@TK2MSFTNGP11.phx.gbl...
Hello,

I am attempting to have a class that I have written serialize so that it
can
be both passed as a parameter or return value for a webservice, and
also be
serialized to disk using the XmlSerializer.

When this class is decalred as a return value for a WebMethod in an
XML WebService I receive the following exception:

System.IO.FileNotFoundException: File or assembly name rexz5r1o.dll,
or one
of its dependencies, was not found.
File name: "rexz5r1o.dll"....

I searched the newgroups for other people that experienced this
problem and
found there to be many - with most of the fixes pointing towards

permission
problems on the temporary folder that the framework writes temporary
assemblies to. I followed the advice given in these posts and gave
the user
account my web service is running under full permission to the folder that was shown in the error log. This did not solve the issue, and I was still receiving the same error message as before.

This got me thinking, so I attempted to serialize this same class in a
simple console application that I can be 100% sure has basically full

local
administrator permissions. I wrote a small application that utilized the XmlSerializer class and got it successfully to serialize a basic class

that
I wrote (not the class mentioned above) that only has a single string
property. I then changed the code to use the class that I wanted to
serialize in the first place thinking it would work - but with no
luck. I received the same error message.

I then decided to mimic my temporary class to look like the real class that
I wanted to have serialized and through trial and error have found the
exception is being caused by an explicit operator on my class that accepts
a
strongly-typed DataRow as a parameter (it also occurs on a basic
System.Data.DataRow class). The exact class that causes this error

can be seen below:

[Serializable]
public class TestClass
{
private string testvalue;

public string TestValue
{
get { return testvalue; }
set { testvalue = value; }
}

public void SetTestValue(string newtestvalue)
{
testvalue = newtestvalue;
}

public static explicit operator TestClass(System.Data.DataRow row)
{
TestClass newclass = new TestClass();
newclass.name = row[0].ToString();

return newclass;
}
}

If you change the parameter type of the explicit operator to a normal

string
type then the exception dissapears.

Just for some background, the class that this is happening on is an

'entity'
that maps a row from a table in a database, which is the reason why I have written an explicit operator to 'map' a DataRow into a corresponding

entity.

Has anyone else come across this issue before? I have searched high

and low
and not yet found anyone that is experiencing this exact problem.

Any insight or help would be greatly appreciated.

Kind regards,

Chris Aitchison
senior developer
Protelligent, Inc.

PS. The source code that I am using to actually perform the

serialization
is
as follows:

FileStream fs = new FileStream("DataFile.dat", FileMode.Create);

try

{

// Construct a BinaryFormatter and use it

// to serialize the data to the stream.

XmlSerializer formatter = new XmlSerializer(typeof(TestBase[]));

//BinaryFormatter formatter = new BinaryFormatter();

// Create an array with multiple elements

TestBase[] a1 = { new TestBase(), new TestBase() };

a1[0].Name = "Hello";

a1[1].Name = "There";

//a1[0].City = "Hello";

//a1[1].City = "There";

// Serialize the array elements.

formatter.Serialize(fs, a1);

// Deserialize the array elements.

fs.Position = 0;

TestBase[] a2 = (TestBase[]) formatter.Deserialize(fs);

}

catch (SerializationException e)

{

Console.WriteLine("Failed to serialize. Reason: " + e.Message);

throw;

}

finally

{

fs.Close();

}



Nov 11 '05 #3

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

Similar topics

0
by: Chris Aitchison | last post by:
Hello, I am attempting to have a class that I have written serialize so that it can be both passed as a parameter or return value for a webservice, and also be serialized to disk using the...
3
by: Integer Software | last post by:
Hi. I have a really simple set of classes that writes 2 pathnames to a xml file. I can write the default ok. Then if I change 1 pathname to a shorter one, then rewrite the xml file, the remains...
2
by: Gary Brewer | last post by:
Below are my classes generated using XSD.EXE from XML/XSLT When I do XmlSerializer xmls=new XmlSerializer(typeof(events)); I get
12
by: SJD | last post by:
I've just read Christoph Schittko's article on XmlSerializer: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnxmlnet/html/trblshtxsd.asp . . . and very informative it is too....
1
by: Vladimir Semenov | last post by:
Hi, I'm trying to serialize a type contained in assembly referering to another assembly in GAC. XmlSerializer xs = new XmlSerializer( typeof(TransferParentData ) ); The code above throws...
4
by: BuddyWork | last post by:
Hello, When running the following line of code XmlSerializer serializer = new XmlSerializer(typeof (MyXmlTestClass)); I get the following exception message. An unhandled exception of
2
by: Michael Brockman | last post by:
I have an ASP.NET custom control that has to serialize the following class in order to save it to view state. If I leave out the parameterless constructor I get: System.IO.FileNotFoundException:...
3
by: David Pendleton | last post by:
Hello all. The following code... Dim objXMLSerializer As XmlSerializer objXMLSerializer = New XmlSerializer(GetType(Settings)) ....generates the following exception in my application...
2
by: dmonder | last post by:
I am using the XMLSerializer to map the XML below to an object as follows: Config config XmlSerializer xmls = new XmlSerializer( typeof( Config ) ); try { TextReader tr = new StreamReader(...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.