dotnet / dotnet/runtime

.NET 11 Preview 7 Unexpectedly Throws `TypeLoadException`

Open
#132,971 3 comments 0 reactions 1 assignee Claimed by @VSadov View on GitHub
area-System.Threading.Tasks blocking bug regression-from-last-release runtime-async
Dominant language
C#
Stars
18.3k
Forks
5.6k
PR merge metrics
PR metrics pending

Description

### Description

I originally reported this [here](https://github.com/dotnet/dotNext/issues/297) as I found it loading types from DotNext.Threading. However, it seems like this may really be an issue with .NET 11 Preview 7.

### Reproduction Steps

To recreate:

* Create a console app with the following settings (note: this should be run with .NET 11 Preview 7)
* `preview`
* `net11.0`
* Reference the DotNext.Threading NuGet package, version 6.6.5
* Add this to Program.cs:
* `_ = typeof(DotNext.Threading.AsyncAutoResetEvent).Assembly.GetTypes();`

### Expected behavior

I would expect this to return the types in the assembly

### Actual behavior

What I get is a `TypeLoadException`:

```
System.TypeLoadException: Method 'get_Task' in type 'DotNext.Threading.Tasks.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.FEC23FF8E24C5C893F2B0DCE3A3DBD6B033A895D525ABEAE11C935B5879FC7CF4__DelayedTaskStateMachine`2' from assembly 'DotNext.Threading, Version=6.6.1.0, Culture=neutral, PublicKeyToken=c8827b44e18fe572' does not have an implementation.
```

### Regression?

Maybe. If I change `TargetFramework` to `net10.0`, it runs fine with no issues.

### Known Workarounds

_No response_

### Configuration

_No response_

### Other information

_No response_

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.