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

后端 未结 11 1867
攒了一身酷
攒了一身酷 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 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;
    
          /// 
          [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.

提交回复
热议问题