How to setup up web.config for WCF IErrorhandler

后端 未结 2 1629
萌比男神i
萌比男神i 2021-02-08 00:36

Can\'t integrate IErrorHandler into my project with the correct web.config

I have a successfully working WCF that is being consumed by webclients in .net 4 but when tryi

2条回答
  •  不要未来只要你来
    2021-02-08 01:15

    It's a bit late, but for other users here is a better approach (in my opinion) and the code above only has to be changed a little bit

    You can change:

        public class WcfErrorServiceBehaviour : IServiceBehavior
    

    to:

        public class WcfErrorServiceBehaviourAttribute : Attribute, IServiceBehavior
    

    Now you can use this as an attribute for your service-class like this:

        [WcfErrorServiceBehaviour]
        [ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall,
                         ConcurrencyMode = ConcurrencyMode.Multiple)]
        public class MXServiceCommands : IMXServiceCommands
        {
        }
    

    Hope this helps some others.

提交回复
热议问题