471,305 Members | 1,415 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,305 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 2936
"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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

8 posts views Thread by Harris Boyce | last post: by
2 posts views Thread by Chris Aitchison | last post: by
3 posts views Thread by Anthony Bouch | last post: by
4 posts views Thread by Andy Neilson | last post: by
1 post views Thread by Jamus Sprinson | last post: by
4 posts views Thread by BuddyWork | last post: by
2 posts views Thread by Chukkalove | last post: by
reply views Thread by rosydwin | last post: by

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.