Skip to content

MethodBase.Invoke can resolve overrides? #10912

Open
@rawling

Description

@rawling

Type of issue

Other (describe below)

Description

The article says

Note that you cannot use the MethodInfo object from the base class to invoke the overridden method in the derived class, because late binding cannot resolve overrides.

I don't get this behaviour. If I call GetMethod on the type of a base class, and then Invoke with an instance of a derived class that overrides the method, I get the overridden result.

I have to call .MethodHandle.GetFunctionPointer and then Activator.CreateInstance if I want to force a call to the base implementation on a derived instance, as per http://stackoverflow.com/questions/4357729/ddg#14415506

Is the documentation wrong, or have I misunderstood it?

Page URL

https://learn.microsoft.com/en-us/dotnet/api/system.reflection.methodbase.invoke?view=net-9.0

Content source URL

https://github.com/dotnet/dotnet-api-docs/blob/main/xml/System.Reflection/MethodBase.xml

Document Version Independent Id

52226c0f-7dec-ed01-fb7a-4a5250bbff56

Article author

@dotnet-bot

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions