Method binding to base method in external library can't handle new virtual methods “between”

后端 未结 2 1694
闹比i
闹比i 2021-02-08 12:27

Lets say I have a library, version 1.0.0, with the following contents:

public class Class1
{
    public virtual void Test()
    {
        Console.WriteLine( \"Li         


        
相关标签:
2条回答
  • 2021-02-08 13:14

    When I build the executable with the first version of the library (I named mine "Thing"), and disassemble it I get:

    L_000d: call instance void [Thing]Thing.Class1::Test()
    

    Rebuilding it with the new DLL referenced:

    L_000d: call instance void [Thing]Thing.Class2::Test()
    

    So that confirms the decision to which method is referred to is made compile-time.

    0 讨论(0)
  • 2021-02-08 13:17

    This was the subject of my blog on March 29th:

    http://blogs.msdn.com/ericlippert/archive/2010/03/29/putting-a-base-in-the-middle.aspx

    Turns out that C# 1.0 did it your way, and that this decision causes some interesting crashes and performance problems. We switched it to do it the new way in C# 2.0.

    I learned a lot from this question. See the blog for details.

    0 讨论(0)
提交回复
热议问题