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

XMLSerializer: Strange exception in serializing arrays -- but only on W2K3

Hi,

I've hit quite a strange problem with XmlSerializer on my W2K3 server. When
I serialize/deserialize using an exe on my local computer (XP), everything
works fine. When I put the code out on the server (W2K3) it throws an
exception. It only seems to happen when serializing/deserializing _arrays_
of a type. If I just serialize/deserialize one instance, it works fine.

The exception I get is: (sorry for the word wrapping.)
System.InvalidOperationException: Unable to generate a temporary class
(result=1).
error CS1514: { expected
error CS1001: Identifier expected
error CS1031: Type expected
error CS1519: Invalid token '{' in class, struct, or interface member
declaration
error CS1514: { expected
error CS1001: Identifier expected
error CS1031: Type expected
error CS1519: Invalid token '{' in class, struct, or interface member
declaration

at System.Xml.Serialization.Compiler.Compile(Assembly parent, String ns,
CompilerParameters parameters, Evidence evidence)
at System.Xml.Serialization.TempAssembly.GenerateAsse mbly(XmlMapping[]
xmlMappings, Type[] types, String defaultNamespace, Evidence evidence,
CompilerParameters parameters, Assembly assembly, Hashtable assemblies)
at System.Xml.Serialization.TempAssembly..ctor(XmlMap ping[] xmlMappings,
Type[] types, String defaultNamespace, String location, Evidence evidence)
at System.Xml.Serialization.XmlSerializer.GenerateTem pAssembly(XmlMapping
xmlMapping, Type type, String defaultNamespace)
at System.Xml.Serialization.XmlSerializer..ctor(Type type, String
defaultNamespace)
at System.Xml.Serialization.XmlSerializer..ctor(Type type)

I have found people with similar problems and they have solved the issue by
granting permission to the Windows\temp directory to the IIS user. I have
granted permissions as needed, I believe. And I am reproducing this running
as an Admin on the box.

Any help would be appreciated. Anyone know how I can find out if it is a
permission issue? Does the XMLSerializer only create temporary classes for
arrays? Any other ideas? (It has to be an environmental issue with the
server, but I have no idea what.)

I have simplified the code down to this:
class Class1
{

[STAThread]
static void Main(string[] args)
{
try
{
TestIntegerArraySerialization();
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}
}

public static void TestIntegerArraySerialization()
{
XmlSerializer xs = new XmlSerializer(typeof(int[])); // <-- exception
thrown here on W2K3
int[] test = new int[1];
test[0] = 10;
System.IO.FileStream fs = new
System.IO.FileStream("out_integer.txt",System.IO.F ileMode.OpenOrCreate);
xs.Serialize(fs, test);
fs.Close();
}
}
Nov 12 '05 #1
3 3121
"token" always means, pay MICROSOFT.

----------------

Some realized that earlier around the Millenium.

----------------

To bad your were one of those that were busy filling SUVs.
=========

"Don McNamara" <don(dot)mcnamara(at)dovestar(dot)com> wrote in message
news:uI**************@TK2MSFTNGP10.phx.gbl...
Hi,

I've hit quite a strange problem with XmlSerializer on my W2K3 server. When I serialize/deserialize using an exe on my local computer (XP), everything
works fine. When I put the code out on the server (W2K3) it throws an
exception. It only seems to happen when serializing/deserializing _arrays_
of a type. If I just serialize/deserialize one instance, it works fine.

The exception I get is: (sorry for the word wrapping.)
System.InvalidOperationException: Unable to generate a temporary class
(result=1).
error CS1514: { expected
error CS1001: Identifier expected
error CS1031: Type expected
error CS1519: Invalid token '{' in class, struct, or interface member
declaration
error CS1514: { expected
error CS1001: Identifier expected
error CS1031: Type expected
error CS1519: Invalid token '{' in class, struct, or interface member
declaration

at System.Xml.Serialization.Compiler.Compile(Assembly parent, String ns, CompilerParameters parameters, Evidence evidence)
at System.Xml.Serialization.TempAssembly.GenerateAsse mbly(XmlMapping[]
xmlMappings, Type[] types, String defaultNamespace, Evidence evidence,
CompilerParameters parameters, Assembly assembly, Hashtable assemblies)
at System.Xml.Serialization.TempAssembly..ctor(XmlMap ping[] xmlMappings, Type[] types, String defaultNamespace, String location, Evidence evidence)
at System.Xml.Serialization.XmlSerializer.GenerateTem pAssembly(XmlMapping xmlMapping, Type type, String defaultNamespace)
at System.Xml.Serialization.XmlSerializer..ctor(Type type, String
defaultNamespace)
at System.Xml.Serialization.XmlSerializer..ctor(Type type)

I have found people with similar problems and they have solved the issue by granting permission to the Windows\temp directory to the IIS user. I have
granted permissions as needed, I believe. And I am reproducing this running as an Admin on the box.

Any help would be appreciated. Anyone know how I can find out if it is a
permission issue? Does the XMLSerializer only create temporary classes for
arrays? Any other ideas? (It has to be an environmental issue with the
server, but I have no idea what.)

I have simplified the code down to this:
class Class1
{

[STAThread]
static void Main(string[] args)
{
try
{
TestIntegerArraySerialization();
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}
}

public static void TestIntegerArraySerialization()
{
XmlSerializer xs = new XmlSerializer(typeof(int[])); // <-- exception
thrown here on W2K3
int[] test = new int[1];
test[0] = 10;
System.IO.FileStream fs = new
System.IO.FileStream("out_integer.txt",System.IO.F ileMode.OpenOrCreate);
xs.Serialize(fs, test);
fs.Close();
}
}


Nov 12 '05 #2
It is likely a permissions problem.
No, XML serializer does not only create temp files for arrays.
have you checked the xmlSerializerPreCompiler? (google it)

Please post when you have more info to share.
-D

"Don McNamara" <don(dot)mcnamara(at)dovestar(dot)com> wrote in message
news:uI**************@TK2MSFTNGP10.phx.gbl...
Hi,

I've hit quite a strange problem with XmlSerializer on my W2K3 server.

When
I serialize/deserialize using an exe on my local computer (XP),
everything
works fine. When I put the code out on the server (W2K3) it throws an
exception. It only seems to happen when serializing/deserializing
_arrays_
of a type. If I just serialize/deserialize one instance, it works fine.

The exception I get is: (sorry for the word wrapping.)
System.InvalidOperationException: Unable to generate a temporary class
(result=1).
error CS1514: { expected
error CS1001: Identifier expected
error CS1031: Type expected
error CS1519: Invalid token '{' in class, struct, or interface member
declaration
error CS1514: { expected
error CS1001: Identifier expected
error CS1031: Type expected
error CS1519: Invalid token '{' in class, struct, or interface member
declaration

at System.Xml.Serialization.Compiler.Compile(Assembly parent, String

ns,
CompilerParameters parameters, Evidence evidence)
at System.Xml.Serialization.TempAssembly.GenerateAsse mbly(XmlMapping[]
xmlMappings, Type[] types, String defaultNamespace, Evidence evidence,
CompilerParameters parameters, Assembly assembly, Hashtable assemblies)
at System.Xml.Serialization.TempAssembly..ctor(XmlMap ping[]

xmlMappings,
Type[] types, String defaultNamespace, String location, Evidence
evidence)
at

System.Xml.Serialization.XmlSerializer.GenerateTem pAssembly(XmlMapping
xmlMapping, Type type, String defaultNamespace)
at System.Xml.Serialization.XmlSerializer..ctor(Type type, String
defaultNamespace)
at System.Xml.Serialization.XmlSerializer..ctor(Type type)

I have found people with similar problems and they have solved the issue

by
granting permission to the Windows\temp directory to the IIS user. I have
granted permissions as needed, I believe. And I am reproducing this

running
as an Admin on the box.

Any help would be appreciated. Anyone know how I can find out if it is a
permission issue? Does the XMLSerializer only create temporary classes
for
arrays? Any other ideas? (It has to be an environmental issue with the
server, but I have no idea what.)

I have simplified the code down to this:
class Class1
{

[STAThread]
static void Main(string[] args)
{
try
{
TestIntegerArraySerialization();
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}
}

public static void TestIntegerArraySerialization()
{
XmlSerializer xs = new XmlSerializer(typeof(int[])); // <-- exception
thrown here on W2K3
int[] test = new int[1];
test[0] = 10;
System.IO.FileStream fs = new
System.IO.FileStream("out_integer.txt",System.IO.F ileMode.OpenOrCreate);
xs.Serialize(fs, test);
fs.Close();
}
}

Nov 12 '05 #3
Thanks Dino.

I looked at the XmlSerializerPreCompile, it takes a type. Any idea how to
pass it an array of a type?

(Just FYI, as a short term fix we rewrote our code and are manually
deserializing the data...)

Don
"Dino Chiesa [Microsoft]" <di****@online.microsoft.com> wrote in message
news:ea**************@tk2msftngp13.phx.gbl...
It is likely a permissions problem.
No, XML serializer does not only create temp files for arrays.
have you checked the xmlSerializerPreCompiler? (google it)

Please post when you have more info to share.
-D

"Don McNamara" <don(dot)mcnamara(at)dovestar(dot)com> wrote in message
news:uI**************@TK2MSFTNGP10.phx.gbl...
Hi,

I've hit quite a strange problem with XmlSerializer on my W2K3 server.

When
I serialize/deserialize using an exe on my local computer (XP),
everything
works fine. When I put the code out on the server (W2K3) it throws an
exception. It only seems to happen when serializing/deserializing
_arrays_
of a type. If I just serialize/deserialize one instance, it works fine.

The exception I get is: (sorry for the word wrapping.)
System.InvalidOperationException: Unable to generate a temporary class
(result=1).
error CS1514: { expected
error CS1001: Identifier expected
error CS1031: Type expected
error CS1519: Invalid token '{' in class, struct, or interface member
declaration
error CS1514: { expected
error CS1001: Identifier expected
error CS1031: Type expected
error CS1519: Invalid token '{' in class, struct, or interface member
declaration

at System.Xml.Serialization.Compiler.Compile(Assembly parent, String

ns,
CompilerParameters parameters, Evidence evidence)
at System.Xml.Serialization.TempAssembly.GenerateAsse mbly(XmlMapping[] xmlMappings, Type[] types, String defaultNamespace, Evidence evidence,
CompilerParameters parameters, Assembly assembly, Hashtable assemblies)
at System.Xml.Serialization.TempAssembly..ctor(XmlMap ping[]

xmlMappings,
Type[] types, String defaultNamespace, String location, Evidence
evidence)
at

System.Xml.Serialization.XmlSerializer.GenerateTem pAssembly(XmlMapping
xmlMapping, Type type, String defaultNamespace)
at System.Xml.Serialization.XmlSerializer..ctor(Type type, String
defaultNamespace)
at System.Xml.Serialization.XmlSerializer..ctor(Type type)

I have found people with similar problems and they have solved the issue
by
granting permission to the Windows\temp directory to the IIS user. I

have granted permissions as needed, I believe. And I am reproducing this

running
as an Admin on the box.

Any help would be appreciated. Anyone know how I can find out if it is a permission issue? Does the XMLSerializer only create temporary classes
for
arrays? Any other ideas? (It has to be an environmental issue with the
server, but I have no idea what.)

I have simplified the code down to this:
class Class1
{

[STAThread]
static void Main(string[] args)
{
try
{
TestIntegerArraySerialization();
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}
}

public static void TestIntegerArraySerialization()
{
XmlSerializer xs = new XmlSerializer(typeof(int[])); // <-- exception
thrown here on W2K3
int[] test = new int[1];
test[0] = 10;
System.IO.FileStream fs = new
System.IO.FileStream("out_integer.txt",System.IO.F ileMode.OpenOrCreate); xs.Serialize(fs, test);
fs.Close();
}
}


Nov 12 '05 #4

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

Similar topics

8
by: Harris Boyce | last post by:
Hello, I'm trying to use the FOR XML EXPLICIT clause with SQL Server to deserialize data from my database into a strongly-typed collection object that I will use throughout my application. I...
2
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: Anthony Bouch | last post by:
Hi I've been reading using the XmlSerializer with custom collections. I've discovered that when serializing a custom collection (a class that implements ICollection, IList etc.) the...
4
by: Andy Neilson | last post by:
I've run across a strange behaviour with XmlSerializer that I'm unable to explain. I came across this while trying to use XmlSerializer to deserialize from a the details of a SoapException. This...
16
by: Bob Rock | last post by:
Hello, when serializing an array of elements of a class Classname using XmlSerializer.Serialize() I get an XML like the following: <?xml version="1.0"> <ArrayOfClassname> ....... ..........
1
by: Jamus Sprinson | last post by:
Before I continue, I'm going to begin by saying I'm not by any means an expert- I've been using .NET with C# for about 4 months now, and basically just learning by example and docs. A game...
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: Chukkalove | last post by:
I'm sorry this message is so long. I have had to make some changes to an application written by a previous developer who used unmanaged serialization to store complex objects to file. The...
0
by: theonlydavewilliams | last post by:
Hi there I'm hoping there's an easy answer to a (hopefully) not too long-winded issue... I'm building a C# web client using a proxy wsdl.exe'd from a wsdl file and six schemas, each in a different...
1
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
0
by: veera ravala | last post by:
ServiceNow is a powerful cloud-based platform that offers a wide range of services to help organizations manage their workflows, operations, and IT services more efficiently. At its core, ServiceNow...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
by: jimatqsi | last post by:
The boss wants the word "CONFIDENTIAL" overlaying certain reports. He wants it large, slanted across the page, on every page, very light gray, outlined letters, not block letters. I thought Word Art...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....

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.