dotnet / dotnet/dotnet-api-docs

MethodBase.Invoke can resolve overrides?

Open
#10,912 0 comments 0 reactions 1 assignee Claimed by @steveharter View on GitHub
area-System.Reflection untriaged
Dominant language
C#
Stars
949
Forks
1.7k
Avg merge
3d 27m
Merged PRs (30d)
49

Description

### 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

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.