I'm aware this is a horrible hack. However...
Say I have assembly A that provides
Cook normally calls
Potato, and I know the methods etc of each. I create assembly B that provides a
SomeNamespace.Potato class that behaves differently to the one in assembly A, but could be called in the same way.
I want to load assemblies A and B into my program, but I want
Cook from A and
Potato from B. Effectively, I'm patching A's
Potato. Can this be done?
EDIT: assembly A is from a third party, I have no control over it.
Unless the classes in the assembly in question has already been built to support others replacing which specific classes/objects to use, then no, you can't do that.
Let me be more specific. There's nothing built into .NET that will allow you to do this.
Your only option then would be to decompile the assembly, change the code, and then recompile it. This may or may not be easy or even possible, depending on what the programmers of it did or thought of.
It looks like this question is essentially what I want to do, and there is a solution (with limitations).