Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7845881
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T17:23:40+00:00 2026-06-02T17:23:40+00:00

I have normal WCF service with few methods. I would like to log some

  • 0

I have normal WCF service with few methods.

I would like to log some information and perform some actions at the beginning of method and in the end.

By implementing IParameterInspector I can easily do lot of logging. Methods BeforeCall and AfterCall give me almost everything I need.

But it doesn’t work for exceptions. There is IErrorHandler, which allows me to perform some handling if exception happened. Drawback is that I don’t know from which method it was thrown. All because IErrorHandler is attached to service behavior, not to operation itself.

However, I can get method name using code below:

((System.Reflection.RuntimeMethodInfo)(exception.TargetSite)).Name == "MyMethod"

This doesn’t look like good idea for me.

Question: Guys, are there any other WCF extensions I can use to achieve my goal? Would you recommend to use old buddy try-catch, and maybe wrap it into some nice syntax so I can perform actions at the beginning and in the end? What would be the syntax? What do you use for similar purposes?

Thanks ahead.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T17:23:44+00:00Added an answer on June 2, 2026 at 5:23 pm

    How about an IOperationInvoker?

    public class NHibernateOperationInvoker : IOperationInvoker {
        private readonly IOperationInvoker _invoker;
        private readonly String _operationName;
    
        public NHibernateOperationInvoker(IOperationInvoker invoker, String operationName) {
            _invoker = invoker;
            _operationName = operationName;
        }
    
        public Object[] AllocateInputs() {
            return _invoker.AllocateInputs();
        }
    
        public Object Invoke(Object instance, Object[] inputs, out Object[] outputs) {
            using (var context = NHibernateContext.CreateNew()) {
                try {
                    var result = _invoker.Invoke(instance, inputs, out outputs);
                    context.Commit();
                    return result;
                } catch(Exception ex) {
                    Debug.Fail("Operation " + _operationName + " failed with " + ex.Message);
                }
            }
        }
    
        public IAsyncResult InvokeBegin(Object instance, Object[] inputs, AsyncCallback callback, Object state) {
            throw new NotImplementedException("NHibernateOperationInvoker.InvokeBegin");
        }
    
        public Object InvokeEnd(Object instance, out Object[] outputs, IAsyncResult result) {
            throw new NotImplementedException("NHibernateOperationInvoker.InvokeEnd");
        }
    
        public Boolean IsSynchronous {
            get { return true; }
        }
    }
    

    This is attached using an IOperationBehavior which does dispatchOperation.Invoker = new NHibernateOperationInvoker(dispatchOperation.Invoker, dispatchOperation.Name);

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have WCF service Service with some method LongTimeMethod. To avoid request timeout I
We have a WCF service that uses Microsoft.Practices.EnterpriseLibrary.Validation and receives an object like so
I have a WCF service that sometimes has to return a Fault. For some
I have normal menu in XAML. And I would like to completely change looks
I have a normal asp.net page containing some code that I want to measure
My service can work with normal WCF calls, but to expose metadata (the wsdl
I have a normal web service. Many java and .net users are accessing it.
I have a WCF service. I can return a concrete class without a problem,
Well, I am thinking in a WCF service per call, and use async methods
I have a WCF service that supposed to provide service to several clients. The

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.