Unable to generate a temporary class

Unable to generate a temporary class

Old forum URL: forums.lhotka.net/forums/t/10569.aspx


RumbleCow posted on Friday, July 29, 2011

Attempting to consume CSLA 4.1 business object via web services and receiving the following exception (constructors were made public):

System.InvalidOperationException: Unable to generate a temporary class (result=1).
error CS0200: Property or indexer 'Csla.Rules.BrokenRule.RuleName' cannot be assigned to -- it is read only
error CS0200: Property or indexer 'Csla.Rules.BrokenRule.Description' cannot be assigned to -- it is read only
error CS0200: Property or indexer 'Csla.Rules.BrokenRule.Property' cannot be assigned to -- it is read only
error CS0200: Property or indexer 'Csla.Rules.BrokenRule.Severity' cannot be assigned to -- it is read only

   at System.Xml.Serialization.Compiler.Compile(Assembly parent, String ns, XmlSerializerCompilerParameters xmlParameters, Evidence evidence)
   at System.Xml.Serialization.TempAssembly.GenerateAssembly(XmlMapping[] xmlMappings, Type[] types, String defaultNamespace, Evidence evidence, XmlSerializerCompilerParameters parameters, Assembly assembly, Hashtable assemblies)
   at System.Xml.Serialization.TempAssembly..ctor(XmlMapping[] xmlMappings, Type[] types, String defaultNamespace, String location, Evidence evidence)
   at System.Xml.Serialization.XmlSerializer.FromMappings(XmlMapping[] mappings, Type type)
   at System.Web.Services.Protocols.XmlReturn.GetInitializers(LogicalMethodInfo[] methodInfos)
   at System.Web.Services.Protocols.XmlReturnWriter.GetInitializers(LogicalMethodInfo[] methodInfos)
   at System.Web.Services.Protocols.MimeFormatter.GetInitializers(Type type, LogicalMethodInfo[] methodInfos)
   at System.Web.Services.Protocols.HttpServerType..ctor(Type type)
   at System.Web.Services.Protocols.HttpServerProtocol.Initialize()
   at System.Web.Services.Protocols.ServerProtocolFactory.Create(Type type, HttpContext context, HttpRequest request, HttpResponse response, Boolean& abortProcessing)

 

RockfordLhotka replied on Friday, July 29, 2011

This is because CSLA objects aren't serializable using the XmlSerializer or DCS:

http://www.lhotka.net/cslanet/faq/XmlServicesFaq.ashx

Copyright (c) Marimer LLC