我在一个配置文件中有以下内容,并且我正在尝试在C#中查找等效位,因为我有一个完全以编程方式配置的服务。我应该寻找什么类/属性/方法?
谢谢。
<behaviors>
<serviceBehaviors>
<behavior name="ServiceGatewayBehavior">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
发布于 2010-12-01 08:07:47
如果要在所有情况下执行此操作,请使用ServiceBehaviorAttribute
[ServiceBehavior(IncludeExceptionDetailInFaults=true)]
class MyServiceImplementation : IMyService
{
/// ...
}
如果您只想在某些情况下执行此操作,请在运行时确定...
////////////////////////////////////
// Must include these at the top of file
using System.ServiceModel;
using System.ServiceModel.Description;
// ...
/////////////////////////////////////////////////////////////
// Inside whichever function initializes the service host
//
_serviceHost = new ServiceHost(_service);
if (IWantToIncludeExceptionDetails())
{
var behavior = _serviceHost.Description.Behaviors.Find<ServiceDebugBehavior>();
behavior.IncludeExceptionDetailInFaults = true;
}
_serviceHost.Open();
https://stackoverflow.com/questions/4319765
复制相似问题