Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using System.Threading.Tasks throws error with .NET 5.0 as build tool. #43458

Closed
ScepticDope opened this issue Nov 11, 2020 · 8 comments
Closed

Comments

@ScepticDope
Copy link

Godot version:
Godot_v3.2.3-stable_mono_win64

OS/device including version:
Windows 10 1909

Issue description:
Ran into this problem while updating an older project to use the latest stable Godot and use dotnet CLI instead of MSBuild.
I started a new project from scratch, only reusing things from my old project. All seems to run fine with my code updated only my async functions throw errors and crash the game when they are called.

Isolated it in the example project. I also made sure that a basic C# CLI project runs the code just fine with my installed .Net build tool so it must be something Godot related.

I got this error instead of my Async function running correctly:

E 0:00:00.539   void Node2D._Ready(): System.TypeLoadException: Could not load type of field 'AudioEffects+<FadeOut>d__0:<>t__builder' (1) due to: Could not resolve type with token 01000017 from typeref (expected class 'System.Runtime.CompilerServices.AsyncVoidMethodBuilder' in assembly 'System.Runtime, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a') assembly:System.Runtime, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a type:System.Runtime.CompilerServices.AsyncVoidMethodBuilder member:(null)
  <C++ Error>   Unhandled exception
  <C++ Source>  *redacted*\2020 - Test\Node2D.cs:15 @ void Node2D._Ready()()
  <Stack Trace> Node2D.cs:15 @ void Node2D._Ready()()

Steps to reproduce:

  1. Install .NET 5.0: SDK 5.0.100
  2. Run: Godot_v3.2.3-stable_mono_win64.exe
  3. Set build tool to: dotnet CLI
  4. Import the example project.
  5. Run the game, see the error.

Minimal reproduction project:
2020 - Test.zip

@ScepticDope
Copy link
Author

ScepticDope commented Nov 11, 2020

Found a fix for it. Changing the .csproj:
<TargetFramework>net5.0</TargetFramework>

to

<TargetFramework>netstandard2.1</TargetFramework>

Fixes it. My guess is that net5.0 is not fully supported, yet? Will that be the case for Godot 4.0 though?

@Calinou
Copy link
Member

Calinou commented Nov 11, 2020

My guess is that net5.0 is not fully supported, yet? Will that be the case for Godot 4.0 though?

See godotengine/godot-proposals#793. From what I've heard, .NET 5.0 is still a bit too unreliable on mobile right now. Hopefully, .NET 6.0 should fare better in this regard.

@aaronfranke
Copy link
Member

aaronfranke commented Nov 12, 2020

Godot uses Mono right now, and that will not change in the near future (and will likely still be the case for 4.0). Mono does not support .NET 5 as a target, only .NET 5 supports .NET 5 as a target right now :)

The default target is net472, if this isn't what Godot generated in your .csproj file then that sounds like a bug.

@CodingMadness
Copy link

Godot uses Mono right now, and that will not change in the near future (and will likely still be the case for 4.0). Mono does not support .NET 5 as a target, only .NET 5 supports .NET 5 as a target right now :)

The default target is net472, if this isn't what Godot generated in your .csproj file then that sounds like a bug.

Why no interesst to change mono to .NET 5?

@aaronfranke
Copy link
Member

@Shpendicus It's not at all that there is no interest. If there was no interest, then godotengine/godot-proposals#793 would be closed. It's just that it won't happen in the near future, .NET 5 literally just came out a few days ago and it's still missing some things.

@CodingMadness
Copy link

@aaronfranke my idea was actually that if ppl could start by now adpoting .NET 5, this time u need to adopt it into Godot, would IMHO be sufficient for .NET 5 to be on a really stable lvl/production useful lvl, so you are working simultaniously with MS .

@GeorgeS2019
Copy link

@akien-mga Same with the latest .NET 5.0.5

Install .NET 5.0: SDK 5.0.202
Run: Godot_v3.3rc7_mono_win64.exe
Set build tool to: dotnet CLI
Import the example project.
Run the game, see the error.

void Node2D._Ready(): System.TypeLoadException: Could not load type of field 'AudioEffects+<FadeOut>d__0:<>t__builder' (1) due to: Could not resolve type with token 01000017 from typeref (expected class 'System.Runtime.CompilerServices.AsyncVoidMethodBuilder'

@neikeq
Copy link
Contributor

neikeq commented Apr 7, 2021

Closing as not a bug. You should be able to use the .NET 5 Sdk to build your project but you cannot set the target framework to .NET 5 as Godot doesn't support that.
We have plans to support .NET 6 in the (near?) future.

@neikeq neikeq closed this as completed Apr 7, 2021
@neikeq neikeq added the archived label Apr 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants