I have a WCF service and I am trying to consume it through a WCF client Library in my web application. For this purpose I created a Console Application, added service reference and tried the following code in Program.cs file inside "main" function.
var factory = new ChannelFactory<IDateTime>("BasicHttpBinding_IDateTime"); var clientChannel = factory.CreateChannel(); var datetime= clientChannel.GetDateTime();
This code works fine. I added a new class (ProxyClient) in the same console application and create a function (GetDateTime) inside the new class and wrote the same code in the function. I added my wcf library reference to my web application and tried to call GetDateTime function through ProxyClient's object But I always get an error on "var factory = new ChannelFactory("BasicHttpBinding_IDateTime")" the error is
Error Message "Could not find endpoint element with name 'BasicHttpBinding_IDateTime' and contract 'DateTimeService.IDateTime' 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"
I am wondering why this is so.