substituting a framework method

  • Thread starter Thread starter lioxa
  • Start date Start date
L

lioxa

Hi,

I need to substitute a method of a Framework built-in class with my
own. Please suggest a way how I can do this (without having to copy/
paste whole source of a particular assembly).

Reflection, probably?

Alexei.
 
Telling us what you are trying to do could hep to raise better suggestions
(for example my first thought would be to just wrap the needed functionality
into my own function but as we don't know what you are trying to do I'm not
sure why the "substitute a method" requirement is needed)...
 
I need to alter functionality of Remoting TcpChannel. I cannot access
target class (transport sink) because it is 'internal'. And
SetupChannel method of TcpChannel class (which I would override to
create my own transport sink, instead of default sink it creates) is
private.

Substituting couple private methods from internal Remoting assembly
classes with my own would help. :)
 
I need to alter functionality of Remoting TcpChannel (in particular,
its transport sink), which is implemented in 'internal' classes and
'private' methods.

Substituting couple classes or methods in this assembly with my own
would help. :)
 
Not familiar but I gave a look and saw that you can apparently use a
contructor to which you can provide your own sink provider as a
IClientChannelSinkProvider, IServerChannelSinkProvider.

If methods are internal and it doesn't fit you are basically stuck with
recompiling your own version (or you could have a look at WCF that could
offer more flexibility depending on your overall goal).

Good luck.
 
Thanks for suggestions, but first isnt possible (transport sinks are
hardcoded), and second (WCF) is .NET 3.0 - I'd prefer to stick to
2.0.

I'm almost sure that with enough permissions I can do what I need -
substitute a framework clas/method with my own (of course in
particular framework instance loaded into my process).

Initial question was - how. :) I see an example in MSDN on how to
attach my own method to any class in runtime (using Reflection),
probably someone familiar with this subject can give me a clue how to
substitute existing method.
 
Back
Top