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

  • SEARCH
  • Home
  • 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 8981707
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T20:24:13+00:00 2026-06-15T20:24:13+00:00

In our external boundaries that expose WCF services, we convert all internal exceptions to

  • 0

In our external boundaries that expose WCF services, we convert all internal exceptions to FaultException. This is a manual process which often has minor flaws unique to each implementation. It has been copy/pasted and mindlessly modified (or forgotten) for each exposed method. To reduce the errors, I wanted to create an aspect which would catch any unhandled exception.

We do a mapping of internal exceptions to fault exceptions. How can I send a mapping function to the aspect?

If I add a property to the aspect like this:

[Serializable]
public sealed class FaultExceptionConverter : OnExceptionAspect {
    public Func<Exception, FaultException> FaultConverter { get; set }
}

I cannot (as expected by Attribute restrictions) initialize it like [FaultExceptionConverter(FaultConverter = MyConversionMethod)] (where MyConversionMethod is some method assignable to Func<Exception, FaultException>). Is there any pattern for passing this type of parameter to the aspect? Many types can be passed into aspects. Is this a common problem?

If there happens to be a better way to accomplish this, I would appreciate the advice.

  • 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-15T20:24:14+00:00Added an answer on June 15, 2026 at 8:24 pm

    I’ve encountered similar frustrating limitations in aspect implementation, and one approach I’ve used to get around them is to have the aspect treat the class it is implemented on as some ‘provider’ type, which it can callback on to request other bits at runtime.

    So, in your case, I imagine an OnException override that looks something like;

    public override void OnException(MethodExecutionArgs args)
    {
        IFaultConverterProvider provider = args.Instance as IFaultConverterProvider;
        if (null != provider)
            Func<Exception, FaultException>exceptionConverterFunc = provider.GetFunc();
    }
    

    Where IFaultConverterProvider is some interface you define and implement on the attributed type to provide the extra parameters you are missing.

    Then, as a bit of a sanity check, you can introduce some compile-time validation into your aspect to ensure that the type it is applied to actually implements this required interface;

    public override bool CompileTimeValidate(Type type)
    {
        if (!type.IsImplementationOf(typeof(IFaultConverterProvider )))
        {
            // The aspect must be in a type which implements IFaultConverterProvider 
            Message.Write(
                MessageLocation.Of(type),
                SeverityType.Error,
                "CUSTOM02",
                "Cannot apply [MyFaultExceptionAspect] to type {0} because it does not implement IFaultConverterProvider .", type);
                return false;
        }
    
        return true;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Windows Service written in C# that handles all of our external
I'm currently improving the part of our COM component that logs all external calls
Many of our users, internal and external, start our web application. Then at some
We're considering setting up a subdomain gateway.domain.com where that sub domain will process all
Our organization currently has an external customer website that allows customers to download files
We have some external APIs in our codebase that have been deprecated over the
I have scripts from external domains that access our api script on our server,
On our server, we have several periodical jobs that login to external accounts through
Our project has a lot of external DLLs, most but not all of which
While defining our application architecture (which contains both web UI and external web services)

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.