2009-07-27 25 views
7

Có ai biết ngoại lệ cụ thể này có ý nghĩa gì không và cách khắc phục?Cơ hội đầu tiên System.Configuration.ConfigurationErrorsException "Phần tử này hiện không được liên kết với bất kỳ ngữ cảnh nào"

Lưu ý rằng tôi không yêu cầu trợ giúp để chặn nó trong hộp thoại Ngoại lệ. Tôi muốn hiểu nguyên nhân gốc rễ của nó và cách tự khắc phục nguyên nhân, nếu có thể.

Cảm ơn.

P.S.

Dòng gây FCE là:

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

chi tiết Ngoại lệ:

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: 

Cuộc gọi chồng là:

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

Sự cố không tự sản xuất sau khi nâng cấp lên .NET 4 và VS2010. Tôi đoán MS đã sửa nó.

+0

Vui lòng cung cấp chi tiết. Bạn có thấy điều này trong trình gỡ rối không? Ngoài ra, vui lòng đăng toàn bộ ngoại lệ. –

Trả lời

5

Tôi đã gặp vấn đề tương tự trong quá khứ khi giao dịch với WCF. Trong trường hợp này, nó đã được cơ bản MS mã nuốt một ngoại lệ nhưng nó vẫn bị bắt như là một FCE khi ở chế độ gỡ lỗi. Xem this link để biết thêm thông tin.

Nếu sự cố của bạn ở WCF, giải pháp thay thế thích hợp là tắt hộp thoại FCE vì bạn không thể thực hiện nhiều việc này. Nếu nó không phải WCF liên quan, tôi nghi ngờ rằng nó có thể là trong một thư viện lớp cơ sở hoặc dll bên thứ ba bạn đang sử dụng. Dù bằng cách nào, không có nhiều bạn có thể làm gì về nó. Theo kinh nghiệm của tôi, tôi chưa bao giờ thấy ngoại lệ này dẫn đến bất cứ điều gì có ý nghĩa.

Nếu bạn cho rằng nó có thể có giá trị nào đó, bạn có thể muốn đăng thêm một chút thông tin ngữ cảnh về nơi ngoại lệ bắt nguồn để mọi người có thể kêu gọi và trợ giúp.

0

Tôi vừa lãng phí một giờ hoặc lâu hơn, sau khi nhấn chính xác cùng một vấn đề.

Tôi có ứng dụng WPF, đã gọi thành công Dịch vụ web và nhận một số dữ liệu.

Nhưng ... sáng nay, tôi đã đi vào hộp thoại Ngoại lệ trong VS2008 và yêu cầu nó ném một ngoại lệ về "Ngoại lệ thời gian chạy ngoại ngữ chung".

Từ đó trở đi, ứng dụng của tôi sẽ sụp đổ ngay sau khi xuất hiện trên dòng để khởi biến webservice của tôi:

MikesWebServiceSoapClient client = new MikesWebServiceSoapClient();

Một ngoại lệ cơ hội đầu tiên của loại 'System.Configuration.ConfigurationErrorsException' xảy ra ở System.Configuration.dll thông tin bổ sung: Phần tử này hiện không được kết hợp với bất kỳ bối cảnh

Tôi đã đọc những ý kiến ​​trong luồng StackOverflow này, nhưng đã bị nhầm lẫn. Trong hộp thoại Ngoại lệ, tôi có thể vô hiệu hóa các ngoại lệ "System.Configuration" khỏi bị ném ... nhưng ngoại lệ này vẫn xảy ra.Và tôi không có bất kỳ ngoại lệ nào khác liên quan đến System.Configuration mà tôi có thể bỏ qua.

Tôi thậm chí còn cố gắng để lại "Ngoại lệ thời gian chạy ngoại lệ phổ biến" được chọn, nhưng không đánh lừa mọi người trong số đó là con cái. Nhưng ứng dụng của tôi vẫn sẽ sụp đổ với một ngoại lệ ...

Cuối cùng, tôi nhận ra rằng trong hộp thoại Exceptions, tôi cần phải thêm một loại ngoại lệ mới gọi là "System.Configuration.ConfigurationErrorsException", nhấp vào OK , sau đó UNTICK loại Ngoại lệ mới này.

Bây giờ, ứng dụng của tôi sẽ chạy, ngoại lệ sẽ xuất hiện âm thầm, nhưng ứng dụng sẽ tiếp tục chạy.

Tôi thích WPF, nhưng thật là vô lý khi tôi lãng phí thời gian để theo đuổi những vấn đề ngớ ngẩn như thế này đã xảy ra trong nhiều năm.

Tôi không bận tâm, nhưng đây là biến WebService được tạo bởi VS2008 ... và nó luôn hoạt động tốt. Cho đến khi bạn hỏi WPF chú ý đến trường hợp ngoại lệ, đó là ...

-1

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

Trung tâm Dữ liệu cho nhà phát triển> đàn Phát triển Nền tảng dữ liệu> WCF Data Services (trước đây gọi là ADO.NET Data Services)> Đầu tiên cơ hội System.Configuration.ConfigurationErrorsException “Đây tố hiện không được kết hợp với bất kỳ bối cảnh”

dịch vụ web Silverlight.

Làm lại ở trên, sau nhiều thử nghiệm, tôi đã tìm thấy những gì hiệu quả để giải quyết lỗi này - bạn thay đổi mọi thứ từ Gỡ lỗi thành Phát hành. Điều này có nghĩa là thay đổi tất cả các thuộc tính như (from = "true") trong tệp web.config, cũng như thiết lập Trình quản lý cấu hình của Visual Studio từ Debug to Release.

Khi bạn thực hiện việc này, lỗi sẽ biến mất. Và cách giải quyết ban đầu của tôi là sai - không cần phải thay đổi từ Tập dữ liệu thành một lớp, như tôi đã đề xuất. Một khi bạn thực hiện thay đổi để phát hành lỗi biến mất.

1

Trong trường hợp của tôi là giải pháp sau đây làm việc:

  1. tôi thấy cấu hình (cài đặt) tập tin, chương trình của tôi được sử dụng (trong các chi tiết ngoại lệ).
  2. Tôi đã ngừng gỡ lỗi.
  3. Tôi đã xóa tệp cấu hình khỏi vị trí, tôi đã tìm thấy.
  4. tôi recompliled ứng dụng của tôi ..

Hope sẽ làm việc trong trường hợp của bạn quá :)

Các vấn đề liên quan