using wcf proxy project instead of app.config files for each client
I have created several WCF services. In order to avoid adding service references in each and every one of my client projects I've created a proxy project which contains all service references and that every project can use as a dll reference. problem is 开发者_开发百科I still need an app.config file in every one of my client projects. which brings me to the question:
Is there a way around this?
or more precise:
Is there a way to make the client project independent of the WCF implementation i use in my proxy project?
In WCF, you can basically always do everything in either config (preferred way for most cases) or in code.
So you could definitely use the generated proxy interfaces and classes, and bake the endpoints etc. into code in your client project.
But again - using the config is usually the preferred way to go (more flexibility). But if you must - you can do (almost) everything using lines of code as well.
If you do want to use config, then you need to add the relevant sections to your client app's config file.
One way to "centralize" and share that information is by putting as much of it as possible into separate config files - e.g. you could have one config file for the behaviors and call it behaviors.config
, have another one with the client settings called clients.config
.
In your client's app, you can then reference those common, shared configs:
<system.serviceModel>
<behaviors configSource="behaviors.config" />
<client configSource="clients.config" />
</system.serviceModel>
You cannot get away without any config at all - but you could definitely centralize and share a good deal of that config stuff once and then reuse it multiple times.
精彩评论