0
votes

I constructed a little solution containing 4 projects:

  • Contract: contains my (t4 generated) entities and interface to my service

  • Service: contains my (t4 generated) context and implementation of my service

  • Host: contains the bare minimum to host a service

ServiceHost host = new ServiceHost(typeof(InleerAppService));

try
{
    host.Open();

    Console.WriteLine("The service is ready!");
    Console.ReadKey();

    host.Close();
}
catch (CommunicationException cex)
{
    Console.WriteLine(cex.Message);
}
  • Client:

var factory = new ChannelFactory("InleerAppService");

IInleerAppService service = factory.CreateChannel();
var result = service.ReturnInput("test string"); // just returns the input string, this works!

Console.WriteLine(result);

var result2 = service.GetAllCompanies(); // this doesn't and crashes the client

foreach (Company c in result2)
{
    Console.WriteLine(c.Name);
}

Console.ReadKey();

You understand I would like to figure out what is going. But I don't really understand how I can debug this. First I start the host with ctrl+F5, then the client. But this doesn't allow me to debug. How should I go to that, using this setup? I know there are more ways to work with services, but for this part I'd just want to focus on this setup.

1

1 Answers

1
votes

You can setup the solution to start multiple projects and just hit F5. To set this up, right click on the solution and go to properties. Select start up project under common properties. And choose both your service and client projects for startup.

Another way to debug is to select the service project, right click and go to debug -> start new instance. Next, do the same thing for client project. Now you should have both service and client projects running under debug mode.