I’m working with a class library named ServiceRef.dll
that includes a WCF service reference. This library is utilized across various parts of our application, such as web applications and other class libraries. It contains necessary <bindings>
and <client endpoints>
for the WCF service.
For the web application, we’ve added the required <bindings>
and <client endpoints>
to the Web.config
file. Similarly, for other class libraries that reference ServiceRef.dll
, we’ve included the same configuration in their respective app.config
files (e.g., abc.dll.config
for abc.dll
).
While the web application hosted on IIS can successfully invoke the WCF service using the endpoint information from Web.config, attempting to do the same from a console library results in the following error:
“Could not find default endpoint element that references contract
‘Service.IService’ in the ServiceModel client configuration section.
This might be because no configuration file was found for your
application, or because no endpoint element matching this contract
could be found in the client element.”
Despite trying various configurations and adding endpoint information to multiple config files for different class libraries, the issue persists.
I’m at a loss to determine which config file the binary is attempting to read for the endpoint information. Is there a way to trace how a binary reads its config/endpoints information when dealing with a class library that has multiple config files? Can this process be logged or captured through tools like Fusion log, Event Viewer, or IIS logs?
Any guidance on this matter would be greatly appreciated.
8
The first thing I want to say is that the web application project is a web.config file. The console project is an app.config file. The missing thing in your question should look like this:
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IService1" />
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:50833/Service1.svc" binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_IService1" contract="ServiceReference1.IService1"
name="BasicHttpBinding_IService1" />
</client>
</system.serviceModel>
I suggest you check your app.config file to see if you have the above code, which you can copy from the web.config file of your web application project.
1