I have a .DLL that makes calls to a WCF service. The DLL is loaded by a separate program that makes method calls to the DLL and the DLL decides whether or not to use WCF by a flag that is passed in the method signatures. This works normally when I have the WCF binding information in the application, but I do not want to have to put the WCF binding information in the application. I have tried the following in my .DLL to get the WCF binding information from the DLL's app.config, but each time I try it, I get the following error:
Could not find endpoint element with name 'Service' and 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 name could be found in the client element.
Here is the code I am using to try and get the WCF binding/settings from the DLL's app.config:
private static readonly Configuration Config = LoadWCFConfiguration();
public void CreateOpsConnection (AccountingOpConnectionDTO opsConnectionDTOFromCaller, bool UseWCFValue)
{
opsConnectionDTO = opsConnectionDTOFromCaller;
UseWCF = UseWCFValue;
if (UseWCF == true)
{
ConfigurationChannelFactory<AccountingOpsServiceReference.IAccountingOperationsService> accountingOpsChannelFactory = new ConfigurationChannelFactory<AccountingOpsServiceReference.IAccountingOperationsService>
("AccountingOperationsService", Config, null);
WCFClient = accountingOpsChannelFactory.CreateChannel();
//WCFClient = new AccountingOpsServiceReference.AccountingOperationsServiceClient();
WCFClient.CreateConnection(opsConnectionDTO);