Debugging a WCF service library - how to start it?

I have a source for two Visual Studio solutions. One of them is the website that calls the WCF service, and the other solution is the WCF service, which compiles into a DLL. The website has a WCF binary DLL service as a reference.

Here's the problem: when I launch the website, an uninsulated exception exits the WCF service.

How to start WCF service in Visual Studio so that I can set breakpoints in WCF service? The service project is configured to compile into DLLs, and I cannot debug DLLs with breakpoints. What do I need to do to “start” the service in an instance of a Visual Studio instance and to throw an exception from starting the website in another instance?

This is my first introduction to WCF.

PS: I tried to add a WCF service project to the website solution and get some error about how I cannot debug it because of the dependencies that the WCF service has, so it doesn’t display an option.

+3
source share
2 answers

You can use WcfSvcHost.exeto host your service and debug it. How is your service arranged? You can also directly connect to the host process while you work, which may be the best solution, since the problem may be environmental.

+5
source

Your service requires a host . In WCF, you have two options:

  • IIS/WAS ( IIS6, HTTP, IIS7/WAS )
  • , Winforms, NT

, , / WcfSvcHost.exe, .

, , " Windows", , :

    static void Main(string[] args)
    {
        using (ServiceHost host = new ServiceHost(typeof(YourWCFService)))
        {
            host.Open();
            Console.WriteLine("Service host running......");

            Console.ReadLine();

            host.Close();
        }
    }

ServiceHost, - . , , , .

+3

Source: https://habr.com/ru/post/1721841/


All Articles