Serialization exception in .NET 4.5

I get this stack trace when I call:

XslCompiledTransform.Transform(XmlDocument.DocumentElement.CreateNavigator(), null, StringWriter) System.Configuration.ConfigurationErrorsException: Configuration system failed to initialize ---> System.Runtime.Serialization.SerializationException: Type is not resolved for member --MyProject stuff at System.AppDomain.GetHostEvidence(Type type) at System.Security.Policy.AppDomainEvidenceFactory.GenerateEvidence(Type evidenceType) at System.Security.Policy.Evidence.GenerateHostEvidence(Type type, Boolean hostCanGenerate) at System.Security.Policy.Evidence.GetHostEvidenceNoLock(Type type) at System.Security.Policy.Evidence.RawEvidenceEnumerator.MoveNext() at System.Security.Policy.Evidence.EvidenceEnumerator.MoveNext() at System.Configuration.ClientConfigPaths.GetEvidenceInfo(AppDomain appDomain, String exePath, String& typeName) at System.Configuration.ClientConfigPaths.GetTypeAndHashSuffix(AppDomain appDomain, String exePath) at System.Configuration.ClientConfigPaths..ctor(String exePath, Boolean includeUserConfig) at System.Configuration.ClientConfigPaths.GetPaths(String exePath, Boolean includeUserConfig) at System.Configuration.ClientConfigurationHost.get_HasRoamingConfig() at System.Configuration.ClientConfigurationHost.IsConfigRecordRequired(String configPath) at System.Configuration.BaseConfigurationRecord.hlNeedsChildFor(String configName) at System.Configuration.Internal.InternalConfigRoot.GetConfigRecord(String configPath) at System.Configuration.ClientConfigurationSystem.OnConfigRemoved(Object sender, InternalConfigEventArgs e) --- End of inner exception stack trace --- at System.Configuration.ConfigurationManager.PrepareConfigSystem() at System.Configuration.ConfigurationManager.GetSection(String sectionName) at System.Xml.XmlConfiguration.XmlReaderSection.get_ProhibitDefaultUrlResolver() at System.Xml.XmlTextReaderImpl.get_IsResolverNull() at System.Xml.Xsl.QueryReaderSettings..ctor(XmlReader reader) at System.Xml.Xsl.Xslt.XsltLoader.Load(Compiler compiler, Object stylesheet, XmlResolver xmlResolver) at System.Xml.Xsl.Xslt.Compiler.Compile(Object stylesheet, XmlResolver xmlResolver, QilExpression& qil) at System.Xml.Xsl.XslCompiledTransform.LoadInternal(Object stylesheet, XsltSettings settings, XmlResolver stylesheetResolver) at System.Xml.Xsl.XslCompiledTransform.Load(XmlReader stylesheet, XsltSettings settings, XmlResolver stylesheetResolver) at MyProject 

XslCompiledTransform Object Loads an XmlReader that uses GetManifestResourceStream into the embedded .xslt file, but I confirmed that it correctly receives this information.

I looked at him quite a bit and narrowed it down to this call, but I'm not sure where to go from here. Has anyone else experienced this?

It was on a Windows 8 machine, but I tested it on server2008r2

+4
source share
1 answer

I am experiencing the same error with .NET 4.5. I see an error when using nunit 2.6+. This happens when you initialize the XmlSerializer in a sub-AppDomain, with objects stored in CallContext. An object type in CallContext cannot be resolved if ApplicationBase (bin-path) is set to a value other than sub-AppDomain. You can see the assembly binding error in the Fusion log viewer: http://msdn.microsoft.com/en-us/library/e74a18c4.aspx

In my case, if I copy the assembly with the type in it to the bin-path, the error will disappear. This, of course, is not a viable solution.

Did you find the root cause of the error?

EDIT: I fixed it by allowing the type to inherit MarshalByRefObject: The type cannot be resolved in UnitTest after moving Project from vs2005 to vs2010 (MSTest)

EDIT 2: An alternative fix is ​​to call System.Configuration.ConfigurationManager.GetSection ("dummy") until the code fails.

+14
source

All Articles