0

In creating my WCF client program, I know that I can set parameters like maxItemsInObjectGraph (or any other) in the app.config file as follows:

<behaviors>
<endpointBehaviors>
  <behavior name="endpointBehavior">
    <dataContractSerializer maxItemsInObjectGraph="2147483647"/>
  </behavior>
</endpointBehaviors>
</behaviors>

But how/where could I hard-code this parameter instead? For what I've read so far it seems that this info can go in the Client's proxy file. Is something like

 [endpointBehaviors(maxItemsInObjectGraph = "2147483647")] 

...at the start of a proxy file the same as the XML above?

I am inferring that syntax based on the text in the question:

The parameter will not change and therefore would be better to hard-code it and not include it in the config file. I just need to know how to take what's in the config file and translate it to hard code

MikeD
  • 171
  • 2
  • 13
  • Possible duplicate of [WCF service: app.config versus attributes or a mixture of both](https://stackoverflow.com/questions/6761105/wcf-service-app-config-versus-attributes-or-a-mixture-of-both). _"Is something like ...at the start of a proxy file the same as the XML above"_ - **yes**. _"[If you want to set additional properties in code, they will overwrite what's already there....Attributes on the service class code are a different story](https://stackoverflow.com/a/6761167/585968)"_ –  Jan 31 '18 at 08:27
  • Sometimes WCF settings in code overrules whats in the config. If your intent is to use config always, then minimize what is in the code so as to avoid confusion and/or guess work –  Jan 31 '18 at 08:31
  • @MickyD I have a config file and I want to take the properties set in that file and instead hard-code them into the program (since they will never be changed and I don't need a config file). My problem is that I don't know how to take the XML file I have and translate it to code – MikeD Jan 31 '18 at 08:45
  • Ah that's a common problem, sadly I could never find a tool for that –  Jan 31 '18 at 09:23

0 Answers0