WCF IncludeExceptionDetailInFaults programmatically?

I have the following in a config file, and I am trying to find the equivalent bits in C#, as I have a service that is configured fully programmatically. What class/property/method should I look for?

Thanks.

<behaviors>
    <serviceBehaviors>
        <behavior name="ServiceGatewayBehavior">
            <serviceMetadata httpGetEnabled="true"/>
            <serviceDebug includeExceptionDetailInFaults="true"/>
        </behavior>
    </serviceBehaviors>
</behaviors>

Answers


If you want to do this in all cases, use the ServiceBehaviorAttribute:

   [ServiceBehavior(IncludeExceptionDetailInFaults=true)]
   class MyServiceImplementation : IMyService
   {
      /// ...
   }

If you want to do it only in some cases, to be determined at runtime....

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

Need Your Help

OpenGL ES2 Alpha test problems

java android 3d opengl-es-2.0 depth-buffer

I am rendering in 3D multiple objects with textures that have alpha. All the textures load fine but when I try to render them in front of each other I get the following:

Unformat money when parsing in PHP

php parsing floating-point currency

Is there a way to get the float value of a string like this: 75,25 €, other than parsefloat(str_replace(',', '.', $var))?