0

I develop a dll that consume one Web Service (wcf), but when I consume this dll in client program I must define a app.config file with the endpoint or the client raise a exception: Could not find default endpoint element that references contract. I don´t want that client program must configure a app.config with the endpoint. It is possible this?

Thanks for reply and excuse my bad english.

Edit: I don´t ask about how to write endpoint in code. I want know if is possible that how the dll know the endpoint, then client code not needs specific endopint (in code or app.config).

Chema
  • 67
  • 4
  • 17
  • Please search before posting questions. This has been covered quite a few times – Jack Ukleja Nov 25 '14 at 13:09
  • I don´t want that clients knows anything about endpoint. I ask if is possible that client programa not need configure endpoint in app.config or client code. – Chema Nov 25 '14 at 15:23
  • You should modify your question then. Currently it says "I don´t want that client program must configure a app.config". It makes no mention of not wanting to use use code – Jack Ukleja Nov 25 '14 at 15:52
  • Did you use "Add Service Reference" to generate the dll that consumes the web service? – Jack Ukleja Nov 25 '14 at 16:01

1 Answers1

0

I'm going to guess you are using a generated client that was created by using "Add Service Reference".

By default creating an instance of that client will look in the app.config for it's endpoint configuration but there is almost certainly an overloaded constructor which allows you to pass in an endpoint so that you no longer need the app.config. Have a look at this question:

Create WCF endpoint configurations in the client app, in code?

Community
  • 1
  • 1
Jack Ukleja
  • 13,061
  • 11
  • 72
  • 113
  • Yes, I use "Add Service Reference". So, always I must write endpoint address in client code? – Chema Nov 26 '14 at 08:51
  • Yes, an endpoint is required. How else is it going to know where to find the service? If you don't use the app.config it must get it from somewhere else...in this case code – Jack Ukleja Nov 26 '14 at 14:11
  • I think that maybe, how the web service is configured into dll, there was a possibility of not configure in client. Only need call method of dll and that is all. Thank for reply – Chema Nov 26 '14 at 15:25