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 6738835
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T11:24:56+00:00 2026-05-26T11:24:56+00:00

In a project, I’m using a Castle Dynamic Proxy to wrap all code run

  • 0

In a project, I’m using a Castle Dynamic Proxy to wrap all code run by a façade in try/catch blocks (sounds odd? Explained here). That works fine, but to make sure all method calls are intercepted, I throw an exception when I come across something non-virtual, using the NonProxyableMemberNotification method of the IProxyGenerationHook interface:

public void NonProxyableMemberNotification(Type type, MemberInfo memberInfo)
{
    throw new InvalidOperationException(string.Format(
          "Proxy failure. {0} {1} in {2} is not virtual.", 
          memberInfo.MemberType, memberInfo.Name, memberInfo.DeclaringType));
}

According to Krzysztof Koźmic’s great tutorial; Object classes are spe­cial cases, and by default Dynam­icProxy will just ignore them. Problem is, in my case they are not ignored, as seen from the following sample MemberInfo data:

memberInfo QuickWatch

Is there something I’ve missed here? Is NonProxyableMemberNotification supposed to fire on Object methods?

I’m using .Net 3.5, VS2010 and Castle Core version 2.5.2, and I’m not overriding Object.GetType() in my XmlDocumentBackend.

  • 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-05-26T11:24:57+00:00Added an answer on May 26, 2026 at 11:24 am

    Use this implementation of NonProxyableMemberNotification:

    public void NonProxyableMemberNotification(Type type, System.Reflection.MemberInfo memberInfo)
        {
            if (memberInfo.DeclaringType != typeof(object))
            {
                string message = string.Format("Non-proxyable member encountered - {0} (type - {1})",
                    memberInfo.Name, type.FullName);
                throw new InvalidOperationException(message);
            }
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My project is based on spring framework 2.5.4. And I try to add aspects
My project is currently using a svn repository which gains several hundred new revisions
Project is C#. So I have a bunch of multithreaded code that is designed
The project I'm working on allows an end-user to modify CSS code to integrate
My project is made out of lots of bits and pieces of older code.
Project Lombok makes it trivial to implement the boilerplate code in the classes. Is
project: Using VB.NET to build a winforms database interface and work-automation app. I am
project: Using VB.NET to build a winforms database interface and work-automation app. I am
Project is to create exe file. If we run exe file it will open
Our project uses XJC to generate Java classes from an XSD. I'm using JAVA

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.