473,480 Members | 1,968 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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 6788
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
813
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
4141
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
2485
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
8447
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
5928
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
2679
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
1511
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
1565
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
2554
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
7055
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7059
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,...
1
6758
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
7010
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...
0
5362
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4799
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3011
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3003
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1311
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.