System.InvalidOperationException: Unable to generate a temporary class (result=1)

后端 未结 11 1754
攒了一身酷
攒了一身酷 2020-12-23 13:19

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

11条回答
  •  隐瞒了意图╮
    2020-12-23 13:41

    XML Serialisation works by generating code to perform the serialisation. This is done in a temporary assembly created for that purpose the first time it is needed.

    However this relies on being able to write the assembly to disk.1

    Your options are either to (1) given the user account which is running the process write permission (for an ASP.NET application this is likely to be a bad idea). (2) Use the SDK tool (sgen.exe) to pre-generate (at development/compile time) the serialisation assembly, and then use (and deplot) that assembly.

    1Open question: the APIs exist to create assemblies dynamically in memory: why not do that?

提交回复
热议问题