Good afternoon!

In principle, this is not a difficult question, but something is confused. So, in a separate project there is a certain WCF service declared as an IMyWCF interface:

 namespace WCF_Service { [ServiceContract] public interface IMyWCF { [OperationContract] bool TestConnection(); } } 

And also in a separate file in the project there is an implementation of this interface:

 namespace WCF_Service { public class MyWCF : IMyWCF { private string msg = string.Empty; // Конструктор public UpdaterService() { string msg = "Hello, WCF!"; MessageBox.Show("Created\n"+msg); } public bool TestConnection() { return true; } } } 

In VS, the service starts, it works out with the help of a studio test client, everything is fine.

Now I need to seize the service, and I try to do it on the basis of a console application that I create in another new project , added usings using System.ServiceModel; And here the most interesting began:

  1. So that the console application “knew” about the service (it’s in another project), I’ll add Add ... -> Service Reference ... where the studio shows me an address like http://localhost:8733/Design_Time_Addresses/WCF_Service/Service1/mex , says that 1 service was found, and only the IMyWCF interface is visible inside the service, the MyWCF class MyWCF not available as a service. Namespace in the dialog box to add links to the service I specify as WCF_ServiceHosting .

  2. After adding the link to the service, I try to execute the following code in the program:

     namespace WCF_ServiceHost { class Program { static void Main(string[] args) { ServiceHost Host = new ServiceHost(typeof(WCF_ServiceHosting.IMyWCF)); Host.Open(); Console.ReadKey(); Host.Close(); } } } 

Of course, he collapses when trying to create a new service host from the IMyWCF interface, but the trouble is that the program does not see the MyWCF class with the implementation of this interface.

A big request to tell how to win and kill the WCF service in the console application.

Of course, googled, watched examples, incl. on MSDN, an example with a calculator, and not only, but there are no such problems anywhere, therefore, I am doing something wrong, the question is what?

UPD. The service is implemented as a separate DLL, through the WCF Service Library template.

  • 2
    Why do you add the Service Reference to yourself? - Pavel Mayorov
  • @PavelMayorov, maybe put it badly, but I add the link to the service from the project of the console application, roughly speaking, to the project in which the service is. - BlackWitcher
  • 2
    So add a link to the project. Why are you making a link to the service? - Pavel Mayorov
  • 3
    A service reference is an auto- generated service client . You can’t please a client :) - Pavel Mayorov
  • @PavelMayorov, yes you are right, of course. I say, confused. Added a link to the library files, everything worked, a service "server" was created and another error "Service" WCF_Service "did not have application endpoints (not infrastructure ones). This may be due to the fact that the configuration file was not found for this application", which is logical, since there is no config yet. But that is another task. Thank you very much! Make out the answer)) - BlackWitcher

0