3

So, locally, I am successfully able to serialize/de-serialize my object which has a Field with a private setter. Now, when I move this same code to other machines, as-is, code runs successfully. However, when I build an msi from this code, in RELEASE mode, the serializer is unable to handle the de-serialization of the very same field in my object. Is there a particular reason why this behavior exists or is allowed?

public class ParentObject
{

   [XmlArray("ChildObjects"), XmlArrayItem("ChildObject")] 
  public  List<ChildObject> ChildObjects{ get; private set; }

}
Kobojunkie
  • 6,375
  • 31
  • 109
  • 164
  • What about msi in debug mode? Or normal application in release mode? Does it error occur only when doing both msi and release? – sisve Oct 17 '13 at 15:32
  • Try using a normal property with backing field and no setter at all. – Ralf Oct 17 '13 at 15:36
  • Not really. The msi in debug works, and the same application in release mode works. But for some reason, on this one machine, it does not de-serialize at all. Throws an unauthorized to write to temp exception – Kobojunkie Oct 17 '13 at 15:43
  • XMLSerializer actually generates temporary assemblies for its workings in the temp folder. http://www.hanselman.com/blog/ChangingWhereXmlSerializerOutputsTemporaryAssemblies.aspx – Ralf Oct 17 '13 at 15:56
  • Look at the stack trace in [this](http://stackoverflow.com/questions/542312/asp-net-access-to-the-temp-directory-is-denied) thread and see if yours looks similar. – Joshua Shearer Oct 17 '13 at 15:58
  • I am trying to understand why this problem even should be a problem in the first place. Is there an assembly out there that may be missing from the remote machine? Trying to maybe sync up the machines to avoid these sort of errors or situations in the future. – Kobojunkie Oct 17 '13 at 16:56
  • . . . as well as understand why the same assemblies would act differently on different machines. – Kobojunkie Oct 17 '13 at 16:57
  • 2
    @Kobojunkie Ähm. On your target machine the user somehow hasn't access rights for the temp folder and XMLSerializer needs that. So the difference ist its allowed on your development machine but not on the target machine. – Ralf Oct 17 '13 at 20:17

1 Answers1

0

For future knowledge seekers, the Issue as listed in the comments by @Ralf is that the XMLSerializer does not have permissions for that specific server to the temp directory.

here is another article that outlines this exact scenario, with some code examples,

ASP.NET Access to the temp directory is denied

Community
  • 1
  • 1
Mabdullah
  • 1,013
  • 6
  • 26