When the type of an invocation target is Object
, and the method being invoked is not a member of Object
., the processing of an invocation expression is deferred until runtime. Late binding also occurs when overload resolution of an invocation target fails solely because one or more arguments were typed as Object
(thus eliminating a method because of a narrowing conversion).
In either of the two cases, all invocation processing including overload resolution is deferred until runtime and the method is late bound. At runtime, normal overload resolution rules are applied to determine the correct method to call. If overload resolution fails at runtime a System.MissingMethodException
exception is thrown.
It is important to note that late bound invocation is done solely off the runtime type of the invocation target and arguments. If an argument's compile time type is Base
, but its runtime type is Dervied
(which derives from Base
), overload resolution will use Derived
as the type used in resolution. It is also important to note that an object's runtime type will never be an interface. Therefore, it is impossible to invoke interface methods in a late bound invocation expression.