You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Odd Reflection Issue Loading DotNext.Threading Types Using Reflection #297
I would expect this to return the types in the assembly. What I get is a TypeLoadException:
System.TypeLoadException: Method 'get_Task' in type 'DotNext.Threading.Tasks.<TaskSchedulerExtensions_T>FEC23FF8E24C5C893F2B0DCE3A3DBD6B033A895D525ABEAE11C935B5879FC7CF4__ImmediateTask`2' from assembly 'DotNext.Threading, Version=6.6.1.0, Culture=neutral, PublicKeyToken=c8827b44e18fe572' does not have an implementation.
System.TypeLoadException: Method 'get_Task' in type 'DotNext.Threading.Tasks.<TaskSchedulerExtensions_T>FEC23FF8E24C5C893F2B0DCE3A3DBD6B033A895D525ABEAE11C935B5879FC7CF4__DelayedTaskStateMachine`2' from assembly 'DotNext.Threading, Version=6.6.1.0, Culture=neutral, PublicKeyToken=c8827b44e18fe572' does not have an implementation.
I'm not sure this is a DotNext-specific issue. It may be something that's broken in the preview version of .NET 11 with the way these types are file scoped. If you feel like this is a general .NET issue, I can file it there, referencing this issue. I did a search for any current issues reported with TypeLoadException and nothing seemed related to this.
I also ran the same code targeting .NET 10 and it works with no issues, so ... I'm guessing this is .NET 11-specific.
I think it's an issue in .NET 11 Reflection subsystem. The issue is related to the fact that ImmediateTask<TArgs, TResult> derives from DelayedTask<TResult> where Task property is overridden as follows:
publicabstractoverrideTask<TResult>Task{get;}
But DelatedTask<TResult> derives from DelayedTask, which defines Task property as
publicabstractTaskTask{get;}
C# allows covariant return types in overrides since version 9.0. It also requires runtime support, which is probably broken in .NET 11 Preview.
@sakno that works fine as well. Reading what the .NET folks are saying on the issue I created, it seems like it's specific to Task-returning methods that are overridden to return Task<T> . It seems like this may already be fixed, just need another release to test the fix.
Activity
sakno commentedon Aug 31, 2026
I think it's an issue in .NET 11 Reflection subsystem. The issue is related to the fact that
ImmediateTask<TArgs, TResult>derives fromDelayedTask<TResult>whereTaskproperty is overridden as follows:But
DelatedTask<TResult>derives fromDelayedTask, which definesTaskproperty asC# allows covariant return types in overrides since version 9.0. It also requires runtime support, which is probably broken in .NET 11 Preview.
sakno commentedon Aug 31, 2026
I think you can verify my hypothesis with similar trick:
Then, load these class by using Reflection.
JasonBock commentedon Aug 31, 2026
@sakno I tried that, but it seems to work:
That prints 4 when I run it, whether I target .NET 10 or .NET 11, and putting them into a separate project didn't seem to matter.
I'll still report this to the .NET runtime repo as I agree, I don't think this is dotNext-specific.
sakno commentedon Sep 1, 2026
Try with generics:
Possibly, some combination of generics and covariant overload raises the exception.
JasonBock commentedon Sep 1, 2026
@sakno that works fine as well. Reading what the .NET folks are saying on the issue I created, it seems like it's specific to
Task-returning methods that are overridden to returnTask<T>. It seems like this may already be fixed, just need another release to test the fix.