I have developed an application using .net 3.5 and have deployed it as an .exe on a number of machines with the same environment. However, on one particular machine I get th
Surfacing @grzenio's comment a bit further for recent users:
If you go to Project Properties -> Build -> Generate serialization assembly -> On, it forces the generation of the XML serializers assembly at compile time, eliminating the need to do so at runtime.
In turn, this means you don't need to change filesystem permissions (useful if you're, for example, hosting on Windows Azure Web Sites, where that isn't an option).
It may be bacause you are switching application pooling identity in IIS
to be password instead of predefined
so you have one off the following
In case this helps anyone, my problem was coming from an inherited class used in the serialization. The problem went away when I made a full copy/paste of my class I was serializing and quit using ineritance. Unfortunately, the advantages of inheritance went away, but that is better than having this problem. (Hey, at least I'm pretty sure that's what solved it. Happened to do a reboot in there somehwere too.)
It may be also just some simple error in the serialized class (typically a result of some copy/paste). For example the following class will cause this error:
public class Foo
{
private string[] contexts;
/// <remarks/>
[System.Xml.Serialization.XmlArrayItemAttribute("Context",
typeof(Property), IsNullable = false)]
public string[] Contexts
{
get { return this.contexts; }
set { this.contexts = value; }
}
}
Notice that typeof(Property) parameter in XmlArrayItem attribute is not compatible (most likely) with string causing similar exception:
System.InvalidOperationException:
Unable to generate a temporary class (result=1).
If typeof(Property) is replaced with typeof(string) serialization will work again.
You only have to give the List Folder Contents and Read permissions on %windir%\Temp.
I found this post when trying to fix my problem, and didn't have to give my user account write access.
From Microsoft