tags:

views:

211

answers:

2

Hi,

it looks like I am not able to succesfully move my WCF proxy code into a separate DLL (as opposed to an EXE as I can see in all the examples I have run into).

The reason I am trying to do this is that I would like my proxy code to be invoked by different clients (possibly unmanaged code), which might not know anything about WCF but just need to access to the services (through a Facade exposed by the proxy maybe?).

Whenever I move the following code that creates a new proxy to a different VS project within the same solution, I get the dreaded "Could not find default endpoint element that references contract 'localhost.IRemoteCommandService' in the ServiceModel client configuration section" exception.

localhost.RemoteCommandServiceClient proxy = 
    new localhost.RemoteCommandServiceClient();

The same code works smoothly whenever used within a Main method in the same project where the proxy code is (auto-generated from Visual Studio).

Any idea? I hope that the client code of my proxy does not need to have the service model XML configuration as the proxy, because that would defeat the purpose I am moving the WCF proxy code into a DLL in the first place.

Thanks, Stefano

+3  A: 

The endpoints are indeed normally specified in the configuration file. You must look at the serviceModel data in the config file, and copy it into your calling app.config - or you need to use the more verbose way of creating the proxies in your code (i.e. specifying the address, binding, configuration etc through code to the constructors).

Marc Gravell
+1  A: 

If you don't want to have to endpoint configuration on the client, you'll have to embed it into your proxy dll by specifying everything in code.

Another option would be to use a dynamic proxy, like this one, which would allow you to not have the serviceModel in your client apps.

Jason Cono
Thank you, coding the end point information did the trick (although I hoped I could have avoided that).
Stefano Ricciardi