Weird “assembly not referenced” error when trying to call a valid method overload

后端 未结 1 823
故里飘歌
故里飘歌 2020-12-17 10:17

I\'m using method overloading in Assembly A:

public static int GetPersonId(EntityDataContext context, string name)
{
    var id = from ... in co         


        
相关标签:
1条回答
  • 2020-12-17 10:50

    The C# standard specifies that overload resolution (section 7.5.3) is performed by comparing each matching signature to determine which is a better fit. It doesn't say what happens when a reference is missing, so we must infer that it still needs to compare those unreferenced types.

    In your case, the compiler needs a reference to EntityDataContext to be able to compare the two overloads. Your call matches the signature exactly so in theory you shouldn't need this, but the standard doesn't specify any such short-circuit behavior.

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