473,608 Members | 2,443 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

XmlSerializer, System.IO.FileN otFoundExceptio n

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.FileN otFoundExceptio n: 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.Dat aRow 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(st ring newtestvalue)
{
testvalue = newtestvalue;
}

public static explicit operator TestClass(Syste m.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("Dat aFile.dat", FileMode.Create );

try

{

// Construct a BinaryFormatter and use it

// to serialize the data to the stream.

XmlSerializer formatter = new XmlSerializer(t ypeof(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.Seria lize(fs, a1);

// Deserialize the array elements.

fs.Position = 0;

TestBase[] a2 = (TestBase[]) formatter.Deser ialize(fs);

}

catch (SerializationE xception e)

{

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

throw;

}

finally

{

fs.Close();

}
Nov 11 '05 #1
2 6810
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.Da taRow' 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#******** ******@tk2msftn gp13.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.s ourceforge.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******** *****@TK2MSFTNG P11.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.FileN otFoundExceptio n: 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.Dat aRow 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(st ring newtestvalue)
{
testvalue = newtestvalue;
}

public static explicit operator TestClass(Syste m.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("Dat aFile.dat", FileMode.Create );

try

{

// Construct a BinaryFormatter and use it

// to serialize the data to the stream.

XmlSerializer formatter = new XmlSerializer(t ypeof(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.Seria lize(fs, a1);

// Deserialize the array elements.

fs.Position = 0;

TestBase[] a2 = (TestBase[]) formatter.Deser ialize(fs);

}

catch (SerializationE xception e)

{

Console.WriteLi ne("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******** ******@TK2MSFTN GP10.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.Da taRow' 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#******** ******@tk2msftn gp13.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.s ourceforge.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******** *****@TK2MSFTNG P11.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.FileN otFoundExceptio n: 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.Dat aRow 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(st ring newtestvalue)
{
testvalue = newtestvalue;
}

public static explicit operator TestClass(Syste m.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("Dat aFile.dat", FileMode.Create );

try

{

// Construct a BinaryFormatter and use it

// to serialize the data to the stream.

XmlSerializer formatter = new XmlSerializer(t ypeof(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.Seria lize(fs, a1);

// Deserialize the array elements.

fs.Position = 0;

TestBase[] a2 = (TestBase[]) formatter.Deser ialize(fs);

}

catch (SerializationE xception e)

{

Console.WriteLi ne("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 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
3
4183
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 of the old pathname, and closing tags are left on the end resulting in an invalid XML file. XmlSerializer.Deserialize gives a System.InvalidOperationException with additional information: Error in the XML document. My default file for example...
2
2496
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
8477
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. I, too, am getting nasty FileNotFound exceptions. I've read, and digested the article, and I think I've found a bug -- it's difficult to track, though it does happen often.
1
5942
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 exception: System.IO.FileNotFoundException : File or assembly name rng0i4ly.dll, or one of its dependencies, was not found. at System.Reflection.Assembly.nLoad(AssemblyName fileName, String codeBase, Boolean isStringized, Evidence assemblySecurity,...
4
2687
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
1520
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: File or assembly name luasprru.dll, or one of its dependencies, was not found. It works if I include a parameterless constructor. Most of the postings regarding this type of error involve incorrect security settings for the Windows temp...
3
1570
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
2568
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( "config.xml" ); config = (Config)xmls.Deserialize( tr ); tr.Close(); } catch (System.IO.FileNotFoundException) {
0
8059
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
8145
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8330
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6011
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
3960
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4023
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2474
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 we have to send another system
1
1589
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1328
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.