.NET 4.5中的序列化异常
发布时间:2020-12-16 23:26:16 所属栏目:百科 来源:网络整理
导读:我打电话时收到这个堆栈跟踪: XslCompiledTransform.Transform(XmlDocument.DocumentElement.CreateNavigator(),null,StringWriter)System.Configuration.ConfigurationErrorsException: Configuration system failed to initialize --- System.Runtime.Ser
我打电话时收到这个堆栈跟踪:
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,XmlResolver stylesheetResolver) at MyProject XslCompiledTransform对象将使用GetManifestResourceStream的XmlReader加载到嵌入的.xslt文件中,但我已确认它正确获取该信息. 我已经看了很多,并把它缩小到这个电话,但我不知道从哪里开始.还有其他人经历过这个吗? 这是在Windows 8机器上,但我在server2008r2操作系统上体验过它 解决方法
我遇到与.NET 4.5相同的错误.我只在使用nunit 2.6时看到错误.当您在子AppDomain中初始化XmlSerializer时,似乎会发生这种情况,其中对象存储在CallContext中.如果将ApplicationBase(bin-path)设置为sub-AppDomain中的不同内容,则无法解析CallContext中对象的类型.您可以在Fusion Log Viewer中看到程序集绑定错误:
http://msdn.microsoft.com/en-us/library/e74a18c4.aspx
在我的情况下,如果我将其中包含类型的程序集复制到nunits bin-path,则错误就会消失.这当然不是一个可行的解决方案. 您是否找到了错误的根本原因? 编辑:我通过让类型继承MarshalByRefObject:Type cant be resolve in UnitTest after migrating Project from vs2005 to vs2010 (MSTest)来修复它 编辑2:替代修复是在失败的代码之前调用System.Configuration.ConfigurationManager.GetSection(“dummy”). (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |