2010-03-20 86 views

回答

95

是的,没错 - 你打开服务主机上的服务器端,之前。然而,这将需要您自托管的WCF服务 - 不会在IIS托管方案的工作:如果你需要做同样的事情在IIS托管

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

ServiceDebugBehavior debug = host.Description.Behaviors.Find<ServiceDebugBehavior>(); 

// if not found - add behavior with setting turned on 
if (debug == null) 
{ 
    host.Description.Behaviors.Add(
     new ServiceDebugBehavior() { IncludeExceptionDetailInFaults = true }); 
} 
else 
{ 
    // make sure setting is turned ON 
    if (!debug.IncludeExceptionDetailInFaults) 
    { 
     debug.IncludeExceptionDetailInFaults = true; 
    } 
} 

host.Open(); 

,你必须创建自己的定制MyServiceHost后裔和合适的MyServiceHostFactory,将实例化这样的定制服务宿主,并在* .svc文件引用该定制服务主机工厂。

+3

保存到本地命名管道WCF应用VS正在运行的服务我的生活设置。谢谢 ! – Larry 2011-07-21 12:19:19

+0

这段代码会进入什么文件? – 2012-05-24 14:46:45

26

您还可以在上面类声明的[ServiceBehavior]标签继承接口

[ServiceBehavior(IncludeExceptionDetailInFaults = true)] 
public class MyClass:IMyService 
{ 
... 
} 
相关问题