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

后端 未结 11 1757
攒了一身酷
攒了一身酷 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:54

    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).

    0 讨论(0)
  • 2020-12-23 13:56

    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

    1. return to predefined
    2. give prmission full control to user IWAM_WBSRV-01 on the windows temp folder
    0 讨论(0)
  • 2020-12-23 13:57

    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.)

    0 讨论(0)
  • 2020-12-23 14:02

    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.

    0 讨论(0)
  • 2020-12-23 14:03

    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

    0 讨论(0)
提交回复
热议问题