【发布时间】: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