Click here to Skip to main content
15,881,709 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I am trying to implement a class library which is used to host a WCF service. It is containing a app.config. The same library I have used in a executable.
When I tried making the class library as executable it is running fine, service host is coming up.
When I refer the dll, and try to do ServiceHost.Open() I get following error:

{"Service 'ServiceClass' has zero application (non-infrastructure) endpoints. This might be because no configuration file was found for your application, or because no service element matching the service name could be found in the configuration file, or because no endpoints were defined in the service element."}

I understood the app.config in dll is not accessible, I tried moving the config to app.config of executable it works.

Is there any way I can access app.config of the dll.

Please Help

What I have tried:

I tried looking for solution to this problem in many blogs, but no concrete solution
Posted
Updated 23-Aug-16 4:47am

1 solution

Rather than creating an endpoint via the app.config, you can do it in code - something along the lines of:

C#
using System.ServiceModel.Description;
.
.
.
Uri baseAddress = new Uri("http://SomePath/MyService.svc");
.
BasicHttpBinding binding = new BasicHttpBinding();
EndpointIdentity identity = EndpointIdentity.CreateDnsIdentity("localhost");
EndpointAddress address = new EndpointAddress(baseAddress, identity);
.
MyService.MyServiceClient client = new MyService.MyServiceClient(binding, address);
client.DoSomething();
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900