2009-07-27 14 views
7

Qualcuno sa cosa significhi questa particolare eccezione e come risolverlo?First chance System.Configuration.ConfigurationErrorsException "Questo elemento non è attualmente associato a nessun contesto"

Nota che non sto chiedendo aiuto per sopprimerlo nella finestra di dialogo Eccezioni. Voglio capire la causa alla radice di esso e come risolvere la causa stessa, se possibile.

Grazie.

P.S.

La riga che causa FCE è:

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

Dettagli eccezione:

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: 

Lo stack di chiamate è:

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# 

EDIT

Il problema non si produce da solo dopo l'aggiornamento a .NET 4 e VS2010. Suppongo che MS l'abbia risolto.

+0

Si prega di fornire dettagli. Stai vedendo questo nel debugger? Inoltre, si prega di inviare l'eccezione completa. –

risposta

5

Ho avuto un problema simile in passato quando si trattava di WCF. In questo caso, era in pratica il codice MS che ingoiava un'eccezione ma era ancora catturato come FCE quando si trovava in modalità di debug. Vedi this link per maggiori informazioni.

Se il problema si verifica in WCF, una soluzione alternativa è sopprimere la finestra di dialogo FCE poiché non è possibile fare molto. Se non è collegato a WCF, sospetto che potrebbe trovarsi in un'altra libreria di classi di base o in una DLL di terze parti che stai utilizzando. In ogni caso, non puoi farci molto. Nella mia esperienza, non ho mai visto questa eccezione portare a qualcosa di significativo.

Se ritieni che possa essere di qualche valore, potresti voler postare un po 'più di informazioni contestuali su dove ha origine l'eccezione, in modo che la gente possa intervenire ed essere di aiuto.

0

Ho appena sprecato un'ora o così, dopo aver colpito esattamente lo stesso problema.

Ho un'app WPF, che stava chiamando con successo un servizio Web e ottenendo alcuni dati.

Ma ... questa mattina, sono entrato nella finestra di dialogo Eccezioni in VS2008 e gli ho chiesto di generare un'eccezione su "Common Language Runtime Exceptions".

Da allora in poi, la mia app potrebbe andare in crash non appena ha colpito la linea per inizializzare la mia variabile webservice:

MikesWebServiceSoapClient client = new MikesWebServiceSoapClient();

Una prima eccezione di possibilità di tipo 'System.Configuration.ConfigurationErrorsException' si è verificato in System.Configuration.dll Ulteriori informazioni: Questo elemento non è attualmente associato a qualsiasi contesto

ho letto i commenti in questo thread StackOverflow, ma è stato confuso. Nella finestra di dialogo Eccezioni, potrei disabilitare le eccezioni "System.Configuration" dall'essere lanciate ... ma questa eccezione si verificherebbe ancora.E non avevo altre eccezioni relative a System.Configuration che avrei potuto deselezionare.

Ho persino provato a lasciare spuntato "Common Language Runtime Exceptions", ma ho disattivato tutti i suoi figli. Ma la mia app sarebbe ancora in crash con un'eccezione ...

Alla fine, mi sono reso conto che nella finestra di dialogo Eccezioni, avevo bisogno di aggiungere un nuovo tipo di eccezione chiamato "System.Configuration.ConfigurationErrorsException", cliccare su OK , quindi SCOLLEGGIA questo nuovo tipo di eccezione.

Ora, la mia app funzionava, l'eccezione si sarebbe verificata silenziosamente, ma l'app continuava a funzionare.

Mi piace il WPF, ma è ridicolo quanto tempo sprecato a rincorrere problemi sciocchi come questo che sono in circolazione da anni.

Non mi dispiacerebbe, ma questa era una variabile WebService creata da VS2008 ... ed è sempre funzionante. Fino a quando si chiede WPF a prestare attenzione alle eccezioni, cioè ...

-1

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

dati Developer Center> Forum di sviluppo della piattaforma dati> WCF Data Services (precedentemente noto come ADO.NET Data Services)> prima possibilità System.Configuration.ConfigurationErrorsException “Questo elemento attualmente non è associato ad alcun contesto”

servizi web Silverlight.

Riprendendo quanto sopra, dopo molte sperimentazioni, ho trovato ciò che funziona per risolvere questo bug - si cambia tutto da Debug a Release. Ciò significa modificare tutti gli attributi, ad esempio (da = "true") nel file web.config, nonché impostare Configuration Manager di Visual Studio da Debug a Release.

Quando si esegue questa operazione, l'errore scompare. E la mia soluzione originale è sbagliata - non c'è bisogno di passare da un dataset a una classe, come ho suggerito. Una volta apportata la modifica a Release, l'errore scompare.

1

Nel mio caso la seguente soluzione ha funzionato:

  1. ho trovato file di configurazione (impostazioni), il mio programma utilizzato (nei dettagli delle eccezioni).
  2. Ho interrotto il debug.
  3. Ho eliminato il file di configurazione dalla posizione, ho trovato.
  4. ho recompliled mia app ..

Speranza funzionerà nel tuo caso troppo :)

Problemi correlati