【问题标题】:Debugging a WCF project调试 WCF 项目
【发布时间】:2011-08-10 09:38:08
【问题描述】:

我构建了一个包含 4 个项目的小解决方案:

  • 合同:包含我的(t4 生成的)实体和我的服务的接口

  • 服务:包含我的(t4 生成的)上下文和我的服务的实现

  • 主机:包含托管服务的最低限度

ServiceHost 主机 = new ServiceHost(typeof(InleerAppService));

try
{
    host.Open();

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

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

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();

你明白我想弄清楚发生了什么。但我真的不明白如何调试它。首先我用 ctrl+F5 启动主机,然后是客户端。但这不允许我调试。我应该如何做到这一点,使用此设置?我知道有更多使用服务的方法,但是对于这一部分,我只想专注于这个设置。

【问题讨论】:

    标签: wcf debugging c#-4.0 entity-framework-4 t4


    【解决方案1】:

    您可以设置解决方案来启动多个项目,然后按 F5。要进行设置,请右键单击解决方案并转到属性。在常用属性下选择启动项目。并选择您的服务和客户项目进行启动。

    另外一种调试方式是选择服务项目,右键调试->启动新实例。接下来,为客户项目做同样的事情。现在您应该在调试模式下运行服务和客户端项目。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-02-08
      • 1970-01-01
      • 1970-01-01
      • 2014-01-25
      • 1970-01-01
      • 2012-07-10
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多