views:

132

answers:

1

We are having a problem whenever our application makes use of the XML Serializer, when we are logged in as a user who has a username containing Japanese characters.

We have prepared a sample application that tests the serializer on its own:

              TestClass myClass = new TestClass();
              myClass.MyString = "Hello World!"; 

              using (MemoryStream stream = new MemoryStream())
              {
                    XmlSerializer serializer = new XmlSerializer(
                          typeof (TestClass));
                    serializer.Serialize(stream, myClass);
              }

              MessageBox.Show("Serialization Complete!");

Where TestClass is defined as:

  [Serializable]
  public class TestClass
  {
        public string MyString { get; set; }
  }

When Serialize() is called, the following exception is reported:

System.InvalidOperationException: Unable to generate a temporary class (result=1). error CS0016: Could not write to output file 'c:\Users\??????\AppData\Local\Temp\qas_8hjs.dll' -- 'The directory name is invalid. '

Note the '?????' where the user name should be displayed.

We have tested this using a user with an English character-set based name, and it is fine.

Is there something we have neglected to set up (for example any environment or AppDomain settings?) or is this a bug in the XML serializer?

I know this is pretty specialist, but any insights whatsoever would be appreciated!

+1  A: 

You could try using SGEN to avoid it having to create the dll at runtime?

However, I would be tempted to log that as a bug on connect.

Note that the SGEN approach won't help web-servers:

These generated assemblies cannot be used on the server side of a Web service. This tool is only for Web service clients and manual serialization scenarios.

Marc Gravell