7

有谁知道这个特殊的异常是什么意思以及如何解决它?

请注意,我不是在“例外”对话框中寻求帮助来抑制它。如果可能的话,我想了解它的根本原因以及如何解决原因本身。

谢谢。

附言

导致 FCE 的行是:

using (ServiceHost host = new ServiceHost(typeof(WcfPortal)))

异常详情:

System.Configuration.ConfigurationErrorsException occurred
  Message="This element is not currently associated with any context"
  Source="System.Configuration"
  BareMessage="This element is not currently associated with any context"
  Line=0
  StackTrace:
       at System.Configuration.ConfigurationElement.get_EvaluationContext()
  InnerException: 

调用栈是:

System.Configuration.dll!System.Configuration.ConfigurationElement.EvaluationContext.get() + 0x64 bytes 
System.ServiceModel.dll!System.ServiceModel.Configuration.ServiceModelExtensionElement.System.ServiceModel.Configuration.IConfigurationContextProviderInternal.GetEvaluationContext() + 0x1f bytes  
System.ServiceModel.dll!System.ServiceModel.Configuration.ConfigurationHelpers.GetEvaluationContext(System.ServiceModel.Configuration.IConfigurationContextProviderInternal provider = {System.ServiceModel.Configuration.ServiceDebugElement}) + 0x41 bytes    
System.ServiceModel.dll!System.ServiceModel.Configuration.ServiceModelExtensionElement.GetConfigurationElementName() + 0x72 bytes   
System.ServiceModel.dll!System.ServiceModel.Configuration.ServiceModelExtensionElement.ConfigurationElementName.get() + 0x3a bytes  
System.ServiceModel.dll!System.ServiceModel.Configuration.ServiceModelExtensionCollectionElement<System.ServiceModel.Configuration.BehaviorExtensionElement>.Add(System.ServiceModel.Configuration.BehaviorExtensionElement element = {System.ServiceModel.Configuration.ServiceDebugElement}) + 0x2a6 bytes    
System.ServiceModel.dll!System.ServiceModel.Configuration.ServiceBehaviorElement.Add(System.ServiceModel.Configuration.BehaviorExtensionElement element = {System.ServiceModel.Configuration.ServiceDebugElement}) + 0x16b bytes    
System.ServiceModel.dll!System.ServiceModel.Configuration.ServiceModelExtensionCollectionElement<System.ServiceModel.Configuration.BehaviorExtensionElement>.DeserializeElementCore(System.Xml.XmlReader reader = {Element, Name="serviceDebug"}) + 0x1eb bytes 
System.ServiceModel.dll!System.ServiceModel.Configuration.ServiceModelExtensionCollectionElement<System.ServiceModel.Configuration.BehaviorExtensionElement>.DeserializeElement(System.Xml.XmlReader reader = {Element, Name="serviceDebug"}, bool serializeCollectionKey = false) + 0x2f bytes 
System.ServiceModel.dll!System.ServiceModel.Configuration.ServiceBehaviorElement.DeserializeElement(System.Xml.XmlReader reader = {Element, Name="serviceDebug"}, bool serializeCollectionKey = false) + 0x2b bytes 
System.Configuration.dll!System.Configuration.ConfigurationElementCollection.OnDeserializeUnrecognizedElement(string elementName = "behavior", System.Xml.XmlReader reader = {Element, Name="serviceDebug"}) + 0xc0 bytes   
System.Configuration.dll!System.Configuration.ConfigurationElement.DeserializeElement(System.Xml.XmlReader reader = {Element, Name="serviceDebug"}, bool serializeCollectionKey = false) + 0xf48 bytes  
System.ServiceModel.dll!System.ServiceModel.Configuration.ServiceBehaviorElementCollection.DeserializeElement(System.Xml.XmlReader reader = {Element, Name="serviceDebug"}, bool serializeCollectionKey = false) + 0x2a bytes   
System.Configuration.dll!System.Configuration.ConfigurationElement.DeserializeElement(System.Xml.XmlReader reader = {Element, Name="serviceDebug"}, bool serializeCollectionKey = false) + 0xe6c bytes  
System.Configuration.dll!System.Configuration.ConfigurationSection.DeserializeSection(System.Xml.XmlReader reader = {Element, Name="serviceDebug"}) + 0x8a bytes    
System.Configuration.dll!System.Configuration.RuntimeConfigurationRecord.RuntimeConfigurationFactory.CreateSectionImpl(System.Configuration.RuntimeConfigurationRecord configRecord = ConfigPath = "MACHINE/EXE", System.Configuration.FactoryRecord factoryRecord = FactoryRecord "system.serviceModel/behaviors", System.Configuration.SectionRecord sectionRecord = SectionRecord "system.serviceModel/behaviors", object parentConfig = {System.ServiceModel.Configuration.BehaviorsSection}, System.Configuration.ConfigXmlReader reader = {Element, Name="serviceDebug"}) + 0xf6 bytes    
System.Configuration.dll!System.Configuration.RuntimeConfigurationRecord.RuntimeConfigurationFactory.CreateSectionWithRestrictedPermissions(System.Configuration.RuntimeConfigurationRecord configRecord = ConfigPath = "MACHINE/EXE", System.Configuration.FactoryRecord factoryRecord = FactoryRecord "system.serviceModel/behaviors", System.Configuration.SectionRecord sectionRecord = SectionRecord "system.serviceModel/behaviors", object parentConfig = {System.ServiceModel.Configuration.BehaviorsSection}, System.Configuration.ConfigXmlReader reader = {Element, Name="serviceDebug"}) + 0x98 bytes   
System.Configuration.dll!System.Configuration.RuntimeConfigurationRecord.RuntimeConfigurationFactory.CreateSection(bool inputIsTrusted = false, System.Configuration.RuntimeConfigurationRecord configRecord = ConfigPath = "MACHINE/EXE", System.Configuration.FactoryRecord factoryRecord = FactoryRecord "system.serviceModel/behaviors", System.Configuration.SectionRecord sectionRecord = SectionRecord "system.serviceModel/behaviors", object parentConfig = {System.ServiceModel.Configuration.BehaviorsSection}, System.Configuration.ConfigXmlReader reader = {Element, Name="serviceDebug"}) + 0x5e bytes   
System.Configuration.dll!System.Configuration.RuntimeConfigurationRecord.CreateSection(bool inputIsTrusted = false, System.Configuration.FactoryRecord factoryRecord = FactoryRecord "system.serviceModel/behaviors", System.Configuration.SectionRecord sectionRecord = SectionRecord "system.serviceModel/behaviors", object parentConfig = {System.ServiceModel.Configuration.BehaviorsSection}, System.Configuration.ConfigXmlReader reader = {Element, Name="serviceDebug"}) + 0x7a bytes  
System.Configuration.dll!System.Configuration.BaseConfigurationRecord.CallCreateSection(bool inputIsTrusted = false, System.Configuration.FactoryRecord factoryRecord = FactoryRecord "system.serviceModel/behaviors", System.Configuration.SectionRecord sectionRecord = SectionRecord "system.serviceModel/behaviors", object parentConfig = {System.ServiceModel.Configuration.BehaviorsSection}, System.Configuration.ConfigXmlReader reader = {Element, Name="serviceDebug"}, string filename = "C:\\Dev\\windows\\bin\\Debug\\Server.Host.exe.Config", int line = 89) + 0x74 bytes    
System.Configuration.dll!System.Configuration.BaseConfigurationRecord.EvaluateOne(string[] keys = {string[2]}, System.Configuration.SectionInput input = SectionInput "system.serviceModel/behaviors", bool isTrusted = false, System.Configuration.FactoryRecord factoryRecord = FactoryRecord "system.serviceModel/behaviors", System.Configuration.SectionRecord sectionRecord = SectionRecord "system.serviceModel/behaviors", object parentResult = {System.ServiceModel.Configuration.BehaviorsSection}) + 0x115 bytes    
System.Configuration.dll!System.Configuration.BaseConfigurationRecord.Evaluate(System.Configuration.FactoryRecord factoryRecord = FactoryRecord "system.serviceModel/behaviors", System.Configuration.SectionRecord sectionRecord = SectionRecord "system.serviceModel/behaviors", object parentResult = {System.ServiceModel.Configuration.BehaviorsSection}, bool getLkg = false, bool getRuntimeObject = true, out object result = null, out object resultRuntimeObject = null) + 0x626 bytes    
System.Configuration.dll!System.Configuration.BaseConfigurationRecord.GetSectionRecursive(string configKey = "system.serviceModel/behaviors", bool getLkg = false, bool checkPermission = true, bool getRuntimeObject = true, bool requestIsHere = true, out object result = null, out object resultRuntimeObject = null) + 0x670 bytes 
System.Configuration.dll!System.Configuration.BaseConfigurationRecord.GetSection(string configKey = "system.serviceModel/behaviors", bool getLkg = false, bool checkPermission = true) + 0x44 bytes 
System.Configuration.dll!System.Configuration.BaseConfigurationRecord.GetSection(string configKey = "system.serviceModel/behaviors") + 0x2a bytes   
System.Configuration.dll!System.Configuration.ContextInformation.GetSection(string sectionName = "system.serviceModel/behaviors") + 0x2a bytes  
System.ServiceModel.dll!System.ServiceModel.Configuration.ConfigurationHelpers.UnsafeGetSectionFromContext(System.Configuration.ContextInformation evalContext = {System.Configuration.ContextInformation}, string sectionPath = "system.serviceModel/behaviors") + 0x3a bytes  
System.ServiceModel.dll!System.ServiceModel.Configuration.ConfigurationHelpers.UnsafeGetAssociatedSection(System.Configuration.ContextInformation evalContext = {System.Configuration.ContextInformation}, string sectionPath = "system.serviceModel/behaviors") + 0x3b bytes   
System.ServiceModel.dll!System.ServiceModel.Configuration.BehaviorsSection.ValidateServiceBehaviorReference(string behaviorConfiguration = "serviceBehavior", System.Configuration.ContextInformation evaluationContext = {System.Configuration.ContextInformation}, System.Configuration.ConfigurationElement configurationElement = {System.ServiceModel.Configuration.ServiceElement}) + 0x66 bytes  
System.ServiceModel.dll!System.ServiceModel.Configuration.ServicesSection.ValidateSection() + 0xe7 bytes    
System.ServiceModel.dll!System.ServiceModel.Configuration.ServicesSection.PostDeserialize() + 0x1e bytes    
System.Configuration.dll!System.Configuration.ConfigurationElement.DeserializeElement(System.Xml.XmlReader reader = {EndElement, Name="services"}, bool serializeCollectionKey = false) + 0x1fef bytes  
System.Configuration.dll!System.Configuration.ConfigurationSection.DeserializeSection(System.Xml.XmlReader reader = {EndElement, Name="services"}) + 0x8a bytes 
System.Configuration.dll!System.Configuration.RuntimeConfigurationRecord.RuntimeConfigurationFactory.CreateSectionImpl(System.Configuration.RuntimeConfigurationRecord configRecord = ConfigPath = "MACHINE/EXE", System.Configuration.FactoryRecord factoryRecord = FactoryRecord "system.serviceModel/services", System.Configuration.SectionRecord sectionRecord = SectionRecord "system.serviceModel/services", object parentConfig = {System.ServiceModel.Configuration.ServicesSection}, System.Configuration.ConfigXmlReader reader = {EndElement, Name="services"}) + 0xf6 bytes    
System.Configuration.dll!System.Configuration.RuntimeConfigurationRecord.RuntimeConfigurationFactory.CreateSectionWithRestrictedPermissions(System.Configuration.RuntimeConfigurationRecord configRecord = ConfigPath = "MACHINE/EXE", System.Configuration.FactoryRecord factoryRecord = FactoryRecord "system.serviceModel/services", System.Configuration.SectionRecord sectionRecord = SectionRecord "system.serviceModel/services", object parentConfig = {System.ServiceModel.Configuration.ServicesSection}, System.Configuration.ConfigXmlReader reader = {EndElement, Name="services"}) + 0x98 bytes   
System.Configuration.dll!System.Configuration.RuntimeConfigurationRecord.RuntimeConfigurationFactory.CreateSection(bool inputIsTrusted = false, System.Configuration.RuntimeConfigurationRecord configRecord = ConfigPath = "MACHINE/EXE", System.Configuration.FactoryRecord factoryRecord = FactoryRecord "system.serviceModel/services", System.Configuration.SectionRecord sectionRecord = SectionRecord "system.serviceModel/services", object parentConfig = {System.ServiceModel.Configuration.ServicesSection}, System.Configuration.ConfigXmlReader reader = {EndElement, Name="services"}) + 0x5e bytes   
System.Configuration.dll!System.Configuration.RuntimeConfigurationRecord.CreateSection(bool inputIsTrusted = false, System.Configuration.FactoryRecord factoryRecord = FactoryRecord "system.serviceModel/services", System.Configuration.SectionRecord sectionRecord = SectionRecord "system.serviceModel/services", object parentConfig = {System.ServiceModel.Configuration.ServicesSection}, System.Configuration.ConfigXmlReader reader = {EndElement, Name="services"}) + 0x7a bytes  
System.Configuration.dll!System.Configuration.BaseConfigurationRecord.CallCreateSection(bool inputIsTrusted = false, System.Configuration.FactoryRecord factoryRecord = FactoryRecord "system.serviceModel/services", System.Configuration.SectionRecord sectionRecord = SectionRecord "system.serviceModel/services", object parentConfig = {System.ServiceModel.Configuration.ServicesSection}, System.Configuration.ConfigXmlReader reader = {EndElement, Name="services"}, string filename = "C:\\Dev\\windows\\bin\\Debug\\Server.Host.exe.Config", int line = 78) + 0x74 bytes    
System.Configuration.dll!System.Configuration.BaseConfigurationRecord.EvaluateOne(string[] keys = {string[2]}, System.Configuration.SectionInput input = SectionInput "system.serviceModel/services", bool isTrusted = false, System.Configuration.FactoryRecord factoryRecord = FactoryRecord "system.serviceModel/services", System.Configuration.SectionRecord sectionRecord = SectionRecord "system.serviceModel/services", object parentResult = {System.ServiceModel.Configuration.ServicesSection}) + 0x115 bytes    
System.Configuration.dll!System.Configuration.BaseConfigurationRecord.Evaluate(System.Configuration.FactoryRecord factoryRecord = FactoryRecord "system.serviceModel/services", System.Configuration.SectionRecord sectionRecord = SectionRecord "system.serviceModel/services", object parentResult = {System.ServiceModel.Configuration.ServicesSection}, bool getLkg = false, bool getRuntimeObject = true, out object result = null, out object resultRuntimeObject = null) + 0x626 bytes   
System.Configuration.dll!System.Configuration.BaseConfigurationRecord.GetSectionRecursive(string configKey = "system.serviceModel/services", bool getLkg = false, bool checkPermission = false, bool getRuntimeObject = true, bool requestIsHere = false, out object result = null, out object resultRuntimeObject = null) + 0x670 bytes    
System.Configuration.dll!System.Configuration.BaseConfigurationRecord.GetSectionRecursive(string configKey = "system.serviceModel/services", bool getLkg = false, bool checkPermission = false, bool getRuntimeObject = true, bool requestIsHere = false, out object result = null, out object resultRuntimeObject = null) + 0x63d bytes    
System.Configuration.dll!System.Configuration.BaseConfigurationRecord.GetSectionRecursive(string configKey = "system.serviceModel/services", bool getLkg = false, bool checkPermission = true, bool getRuntimeObject = true, bool requestIsHere = true, out object result = null, out object resultRuntimeObject = null) + 0x63d bytes  
System.Configuration.dll!System.Configuration.BaseConfigurationRecord.GetSection(string configKey = "system.serviceModel/services", bool getLkg = false, bool checkPermission = true) + 0x44 bytes  
System.Configuration.dll!System.Configuration.BaseConfigurationRecord.GetSection(string configKey = "system.serviceModel/services") + 0x2a bytes    
System.Configuration.dll!System.Configuration.ClientConfigurationSystem.System.Configuration.Internal.IInternalConfigSystem.GetSection(string sectionName = "system.serviceModel/services") + 0x7e bytes    
System.Configuration.dll!System.Configuration.ConfigurationManager.GetSection(string sectionName = "system.serviceModel/services") + 0x48 bytes 
System.ServiceModel.dll!System.ServiceModel.Configuration.ConfigurationHelpers.UnsafeGetSectionFromConfigurationManager(string sectionPath = "system.serviceModel/services") + 0x31 bytes   
System.ServiceModel.dll!System.ServiceModel.Configuration.ConfigurationHelpers.UnsafeGetAssociatedSection(System.Configuration.ContextInformation evalContext = null, string sectionPath = "system.serviceModel/services") + 0xac bytes 
System.ServiceModel.dll!System.ServiceModel.Configuration.ConfigurationHelpers.UnsafeGetSection(string sectionPath = "system.serviceModel/services") + 0x22 bytes   
System.ServiceModel.dll!System.ServiceModel.Configuration.ServicesSection.UnsafeGetSection() + 0x26 bytes   
System.ServiceModel.dll!System.ServiceModel.Description.ConfigLoader.LookupService(string serviceConfigurationName = "Csla.Server.Hosts.WcfPortal") + 0x39 bytes    
System.ServiceModel.dll!System.ServiceModel.ServiceHostBase.LoadConfigurationSectionInternal(System.ServiceModel.Description.ConfigLoader configLoader = {System.ServiceModel.Description.ConfigLoader}, System.ServiceModel.Description.ServiceDescription description = ServiceType={Csla.Server.Hosts.WcfPortal}, string configurationName = "Csla.Server.Hosts.WcfPortal") + 0x2d bytes 
System.ServiceModel.dll!System.ServiceModel.ServiceHostBase.ApplyConfiguration() + 0xfa bytes   
System.ServiceModel.dll!System.ServiceModel.ServiceHostBase.InitializeDescription(System.ServiceModel.UriSchemeKeyedCollection baseAddresses = {System.ServiceModel.UriSchemeKeyedCollection}) + 0xf8 bytes 
System.ServiceModel.dll!System.ServiceModel.ServiceHost.InitializeDescription(System.Type serviceType = {Name = "WcfPortal" FullName = "Csla.Server.Hosts.WcfPortal"}, System.ServiceModel.UriSchemeKeyedCollection baseAddresses = {System.ServiceModel.UriSchemeKeyedCollection}) + 0x83 bytes    
System.ServiceModel.dll!System.ServiceModel.ServiceHost.ServiceHost(System.Type serviceType = {Name = "WcfPortal" FullName = "Csla.Server.Hosts.WcfPortal"}, System.Uri[] baseAddresses = {System.Uri[0]}) + 0x16a bytes    
Server.Host.exe!Server.Host.Program.Main(string[] args = {string[0]}) Line 37 + 0x38 bytes  C#

编辑

升级到 .NET 4 和 VS2010 后,该问题不会自行产生。我猜MS修复了它。

4

4 回答 4

5

我过去在处理 WCF 时遇到过类似的问题。在这种情况下,它基本上是 MS 代码吞下了一个异常,但在调试模式下它仍然被捕获为 FCE。有关更多信息,请参阅此链接

如果您的问题出在 WCF 中,则适当的解决方法是抑制 FCE 对话框,因为您对此无能为力。如果它与 WCF 无关,我怀疑它可能位于您正在使用的另一个基类库或第三方 dll 中。无论哪种方式,您都无能为力。以我的经验,我从未见过这个例外会导致任何有意义的事情。

如果您认为它可能具有一定的价值,您可能希望发布更多有关异常起源的上下文信息,以便人们可以插话并提供帮助。

于 2009-07-27T17:10:20.253 回答
1

就我而言,以下解决方案有效:

  1. 我找到了配置(设置)文件,我使用的程序(在异常详细信息中)。
  2. 我停止调试。
  3. 我从该位置删除了配置文件,我发现。
  4. 我重新编译了我的应用程序..

希望也适用于您的情况:)

于 2011-05-12T20:36:43.033 回答
0

在遇到完全相同的问题后,我刚刚浪费了一个小时左右。

我有一个 WPF 应用程序,它成功调用了 Web 服务并获取了一些数据。

但是......今天早上,我进入了VS2008中的异常对话框,并要求它在“公共语言运行时异常”上抛出异常。

从那时起,我的应用程序将在启动我的 webservice 变量时立即崩溃:

MikesWebServiceSoapClient 客户端 = 新 MikesWebServiceSoapClient ();

System.Configuration.dll 中出现“System.Configuration.ConfigurationErrorsException”类型的第一次机会异常附加信息:此元素当前未与任何上下文关联

我确实阅读了这个 StackOverflow 线程中的评论,但很困惑。在“异常”对话框中,我可以禁用“System.Configuration”异常被抛出......但这个异常仍然会发生。而且我没有任何其他与 System.Configuration 相关的例外情况可以取消。

我什至尝试勾选“公共语言运行时异常”,但不勾选它的每个子项。但是我的应用程序仍然会崩溃并出现异常......

最后,我意识到在 Exceptions 对话框中,我需要添加一个名为“ System.Configuration.ConfigurationErrorsException ”的新 Exception 类型,单击 OK,然后 UNTICK 这个新的 Exception 类型。

现在,我的应用程序将运行,异常将静默发生,但应用程序将继续运行。

我确实喜欢 WPF,但我浪费了多少时间来解决已经存在多年的此类愚蠢问题,这太荒谬了。

我不介意,但这是一个由 VS2008 创建的 WebService 变量......而且它总是运行良好。直到您要求 WPF 关注异常,即...

于 2010-08-10T12:58:01.743 回答
-1

http://social.msdn.microsoft.com/Forums/en-US/adodotnetdataservices/thread/e2d07245-b305-4d12-82e5-6074175271d6

数据开发者中心 > 数据平台开发论坛 > WCF 数据服务(以前称为 ADO.NET 数据服务) > 第一次机会 System.Configuration.ConfigurationErrorsException “此元素当前未与任何上下文关联”</p>

Silverlight 网络服务。

重复上述内容,经过大量实验,我找到了解决此错误的方法——您将所有内容从 Debug 更改为 Release。这意味着更改 web.config 文件中的所有属性,例如 (from ="true"),以及将 Visual Studio 的配置管理器从 Debug 设置为 Release。

执行此操作时,错误会消失。而且我最初的解决方法是错误的——正如我所建议的,不需要从数据集更改为类。一旦您对 Release 进行更改,该错误就会消失。

于 2010-08-30T01:25:36.100 回答