问题:如何调试WCF服务 - 我无法点击服务中的断点
使用VS2012和NUnit / TestDriven
只要我在WcfHostApplication上按Ctrl F5之前启动了服务,我就可以运行我的测试。我在Visual Studio中托管。
尝试将Web.Config放入WcfHostConsoleApplication并将debug设置为true。
此示例应用来自here
//hack to get working as we're not using wsdl yet...mimicking what happens in wsdl
[ServiceContract(Namespace = "http://www.programgood.net/examples/2012/09/wcf")]
public interface IHelloWcfService
{
[OperationContract]
string SayHello(string msg);
}
namespace HelloWcfTests
{
[TestFixture]
public class HelloWcfServiceLibrary_Tests
{
[Test]
public void SayHello_GivenHello_ShouldReturn()
{
//in reality add Service Ref.. using another special interface called IMetaDataExchange
IHelloWcfService proxy = ChannelFactory<IHelloWcfService>.CreateChannel(
new NetTcpBinding(),
new EndpointAddress("net.tcp://localhost:9000/HelloWcfEndPoint"));
string msg = "hello";
string result = proxy.SayHello(msg);
StringAssert.StartsWith("You entered: hello", result);
}
}
}
答案 0 :(得分:1)
不要使用Ctrl + F5启动服务,因为它将启动您的服务而无需调试。
用F5开始。