views:

49

answers:

1

Hi, i'm developing an enterprise application using asp.net mvc, wf-wcf services and normal wcf. I want use a unique point of view of unmanaged exception and my problem is integrate wf-wcf services with ELMAH. The problem is that in wf-wcf i can't decorate di class with the elmah attribute so i make that using web.config if is possible. Someone can help me? (here is a discussion how integrate elmah with wcf using attribute http://stackoverflow.com/questions/895901/exception-logging-for-wcf-services-using-elmah)

thanks in advance F.

+1  A: 

Interesting, hadn't thought of that before, as ELMAH is an awesome addon for websites.

The same approach should work for WF services. The way to add the ServiceErrorBehaviourAttribute in the config file is by using a BehaviorExtensionElement. The following code should do the trick

public class ServiceErrorBehaviourElement : BehaviorExtensionElement {
    public override Type BehaviorType {
        get { return typeof(ServiceErrorBehaviourAttribute); }
    }

    protected override object CreateBehavior() {
        return new ServiceErrorBehaviourAttribute();
    }
}

Register the type to the behaviorExtensions and you can the behavior to your workflow service serviceBehaviors element.

Maurice
it works only if the exception are raised when the persistence store are disabled(in other words without Appfabric). Otherwise probably because the workflow "forget" to be hosted in a wcf and have the context to null the behavior don't fire
tartafe
Not sure I understand, The IErrorHandler is part of the WCF callstack and only in play during WCF messages. Do you mean that when a WCF message causes a workflow to be loaded from the store it doesn't trap the error? Or are you referring to errors at some other time in the workflow lifespan?
Maurice
the problem is that when a WCF message causes a workflow to be loaded from the store it doesn't trap the error ( sorry for my poor english).
tartafe
Finally managed to have a good look at this and I didn't have any problems with a workflow after it had been persisted and reloaded as long as I had aspNetCompatibilityEnabled set to true. The real problem with using Elmah is that is only capable of trapping errors during a WCF request and not while the workflow is running between different requests, something that makes this less useful for error monitoring with workflow services.
Maurice