Rob Ford (FIS)

I'm experiencing several System.Configuration.ConfigurationErrorsException exceptions when adding the dataContractSerializer to a behavior

<system.serviceModel>
<behaviors>
<endpointBehaviors>
<behavior name="CalculatorBehavior">
<dataContractSerializer maxItemsInObjectGraph="165536" />
</behavior>
</endpointBehaviors>
</behaviors>
</system.serviceModel>

The error I get is "This element is not currently associated with any context".

The exceptions are handled internally by WCF. The errors don't stop the app from running and using the service and once the entire config has been loaded it seems the error condition disappears.

For each behavior defined with a dataContractSerializer we'll see 2 exceptions. This is causing our application startup time to reach unacceptable levels.

many thanks

Rob



Re: Windows Communication Foundation (Indigo) ConfigurationErrorsException when using dataContractSerializer

Cory Cundy

I am experiencing the same as Rob is. I am getting this when I add service behaviors through the Service Configuration Editor. WCF is swalling a

<system.serviceModel>

<behaviors>

<serviceBehaviors>

<behavior name="ServiceBehavior">

<serviceDebug />

<serviceMetadata />

</behavior>

</serviceBehaviors>

</behaviors>

......

When you change your exception handling to catch exceptions in the Exception Window (Ctrl-Alt-E) it is swallowing several exceptions. Why is this happening The application still seems to run alright, but this doesn't seem right. Any ideas

It is very easy to reproduce.

Cory





Re: Windows Communication Foundation (Indigo) ConfigurationErrorsException when using dataContractSerializer

Mohammad Makarechian - MSFT

Hello,

MaxItemsInObjectGraph is a service (not endpoint) behaviour attribute, so if you change your config to the following (but do change the name property of the service attribute, below), it should resolve your issue:

<configuration>

<system.serviceModel>

<services>

<service name="YourServiceNamespace.YourServiceClass" behaviorConfiguration="ReproBehavior" />

</services>

<behaviors>

<serviceBehaviors>

<behavior name="ReproBehavior">

<dataContractSerializer maxItemsInObjectGraph="165536" />

</behavior>

</serviceBehaviors>

</behaviors>

</system.serviceModel>

</configuration>

Please post back if this does not address your issue.

Thanks.





Re: Windows Communication Foundation (Indigo) ConfigurationErrorsException when using dataContractSerializer

Cory Cundy

This does not help my problem. I have the configuration I mentioned above that outputs empty serviceDebug and serviceMetadata behaviors and I am still getting the error. I have tried many combinations of their attributes as well with no luck. I am getting a "This element is not currently associated with any context" exception. When I take the <service behaviorConfiguration="ServiceBehavior" ...> attribute out, then I do not get the exception. I am getting the exception on a line of code that looks like the following.

For i As Int32 = 0 To serviceModelConfig.Services.Services.Count - 1

It has to be happening somewhere within the serviceModelConfig object. I get the exception here twice. This is easy to reproduct. I even used the Service Configuration Tool to create the configuration settings.

Any other ideas

Cory





Re: Windows Communication Foundation (Indigo) ConfigurationErrorsException when using dataContractSerializer

Drew Noakes

Sadly this didn't help in our case. Has anyone else worked out how to get around these 'silent' errors which are so annoying when you run your app with break-on-all-errors





Re: Windows Communication Foundation (Indigo) ConfigurationErrorsException when using dataContractSerializer

Brian McNamara - MSFT

I doubt it, I think this happens all the time. It is a shame to have exceptions thrown-and-caught in the system during normal working operation, but I think the code we shipped does this (unfortunately I don't know the underlying reason). In any case, I doubt there is any way to work around it.




Re: Windows Communication Foundation (Indigo) ConfigurationErrorsException when using dataContractSerializer

AronW

Check it out...

Just add "System.Configuration.ConfigurationErrorsException" to your exceptions and uncheck the box telling the debugger to break on it.

It's a crappy work around for something that should not be happening (I'm looking at you MS), but it works.

-Aron





Re: Windows Communication Foundation (Indigo) ConfigurationErrorsException when using dataContractSerializer

Donald Roy Airey

I ran across this error with the example code downloaded from the Microsoft site. This raises the question: Is WCF ready for prime time Is there anyone here who's done something other than a prototype with this technology