0

I have a similar situation like here: Dynamically add reference of WCF service

However, there is one class library, which references a WCF service - let's call it CL1. Then there are multiple projects - let's call them P1 and P2 - which reference to CL1.

How it looks like now: There are two versions of CL1, just because I don't know how to dynamically add a wcf service reference. So it looks like this:

P1 uses CL1 Version 1.

P2 uses CL1 Version 2.

However, I would rather inject the URL of the service from PL1 and PL2 into CL1. So I don't have to maintain two versions!

So it should rather look like this:

Goal

P1 and P2 inject Service-URL into CL1. CL1 adds or updates the service reference (generate reference.cs and rebuilds itself).

Any ideas of how I could achieve this? Or may there be better approaches?

Community
  • 1
  • 1
Fabian Bigler
  • 10,403
  • 6
  • 47
  • 70
  • CL1 and CL2 are two separate ClassLibrary-projects with the same content that just differ in their app.configs? – Jan Köhler Jul 13 '15 at 05:59
  • @khlr The reference.cs also varies (The meta-data from the service reference are different). Everything else is the same. – Fabian Bigler Jul 13 '15 at 06:29
  • [This](http://stackoverflow.com/questions/5036308/dynamically-switch-wcf-web-service-reference-url-path-through-config-file) may already do the trick for you (can't say for sure, as you've not yet posted any relevant code). Apart from that you could dynamically create your proxy using the [ChannelFactory](https://msdn.microsoft.com/library/ms576132.aspx). – Jan Köhler Jul 13 '15 at 09:34

0 Answers0