ConfigurationErrorsException: This element is not

2019-02-16 21:06发布

问题:

I am getting strange exception which seems to me is related to WCF configuration object but what is wrong is completely unclear to me

A first chance exception of type 'System.Configuration.ConfigurationErrorsException' occurred in System.Configuration.dll

Additional information: This element is not currently associated with any context

ServiceModelSectionGroup serviceConfigs =
ServiceModelSectionGroup.GetSectionGroup(config);

ServiceElement serviceConfig = 
serviceConfigs.Services.Services[serviceType.ToString()]; << here exception

回答1:

Looks like a lot of other people have solved this problem just by disabling breaking on this exception - see here, here, here and here, for example. Nobody seems to have any idea what use this exception is, though.

I should add that I had to add the exception manually to my Debug/Exceptions list - it didn't appear by default.



回答2:

I was able to fix this issue by deleting everything in the bin folder and rebuilding the solution.