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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T20:36:11+00:00 2026-06-08T20:36:11+00:00

I think what I need is something the .net folks call transparent dynamic proxy,

  • 0

I think what I need is something the .net folks call “transparent dynamic proxy”, but all the implementations I’ve seen this far (Castle DynamicProxy, Spring.NET AOP, etc) require me to do at least one of these:

  1. Declare intercepted method as virtual
  2. Wrap class and create instances of the wrapper instead of wrapped class
  3. Change inheritance or implement interfaces

Obviously, if both caller and callee are nonvirtual and from thirdy-party closed source libraries, which is the case, there is nothing I can do.

If C# were a dynamic language like Python I would do something like this:

foo = ThirdyPartyLibA.Foo()
def interceptor(self, *args, **kwargs):
    do_something_before(self, *args, **kwargs)
    result = ThirdyPartyLibB.Bar.intercepted(self, *args, **kwargs)
    do_something_after(self, result, *args, **kwargs)
    return result
foo.bar.intercepted = interceptor # bar is an instance of ThirdyPartyLibB.Bar
foo.do_its_job() # Foo.do_its_job calls Bar.intercepted

I need this to change a bad behavior of ThirdyPartyLibA.Foo while interacting with ThirdyPartyLibB.Bar. I know exactly what causes this behavior and exactly how to change Foo or Bar to fix this bug thanks to dissasemblers.

Some (very unlikely to work) ideas:

  • Disassemble ThirdyPartyLibA, make changes in code and generate a compatible assembly (unlikely to work because it’s a strong-named assembly)
  • Edit binary to make Foo’s buggy methods virtual and change whatever is necessary for it to remain a valid assembly so I can use dynamic proxies (very unlikely to work, also because of the same reason as the idea above)
  • Find a transparent dynamic proxy implementation that fits (I think there is none based on this forum thread: http://www.pcreview.co.uk/forums/overriding-non-virtual-methods-using-il-and-reflection-emit-t2605695.html)
  • Contact the company that created the library (they don’t support the product anymore)
  • Stop using the library or use an alternative (impossible, since it’s part of the runtime of a RAD IDE that we are tied to because there is a HUGE amount of code written using the IDE own language)
  • Control the calls to the problematic methods to avoid the bug (we already did this but it didn’t solve the problem completely)

Do you have any other idea?

PS: Sorry for my bad english. Also, sorry for my Python. This code is here just to illustrate what I need, don’t take it as a recipe because it’s horrible.

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

    Possible Solution 1:

    Wrap the library and using a tool like ReSharper to find all usages of the library and replace with the wrapper class. You could also use that opportunity to clean up the presumably crappy interface of the third party library.

    Possible Solution 2:

    While TypeMock is generally used as a testing tool, it will allow you to mock everything. Because it injects itself as a code profiler, the stuff you can mock included private and static members of classes. As a bonus, any overridden methods do not need to be virtual, so you may be able to intercept the calls that way.

    My recommendation

    I would recommend you go with Solution 1. A wrapper is very easy to understand, and it’ll give you a good opportunity to really improve the code. I’d even recommend that you wrap third party libraries as a general rule.

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

Sidebar

Related Questions

I think it's got something to do with the nested functions, but they need
I think I need something akin to a rails eager loaded query with a
I think I might need to do something like the following pseudo-code in my
I don't think I need to post my code (there's lots of it) but
Okay, I think I need another pair of eyes to look over this. I'm
This SQL statement example is very close to what I think I need... update
I'm confused regarding each() and .each()... I think I need to use both, but
I am using asp.net MVC with the asp.net membership but I starting to think
I have a need for a fairly specialised collection .NET, and I don't think
I think I need a reverse version of strtok, like: char* p = rstrtok(str,

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.