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:
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 theIMyWCFinterface is visible inside the service, theMyWCFclassMyWCFnot available as a service. Namespace in the dialog box to add links to the service I specify asWCF_ServiceHosting.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.