-
-
Notifications
You must be signed in to change notification settings - Fork 21.3k
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
C# class not found after playing project #47459
Comments
I tested your project in 3.3 RC 6, it seems to fail building with these errors:
This comes from this attribute in
I guess it might be something used in the |
I'm sorry! I just found the issue where this is mentioned #46713 Thank you @akien-mga for checking out the issue and @Calinou for your quick responses |
Not fixed. You shouldn't add those attributes manually. They should be auto-generated. |
I don't see which version of the .NET SDK being used--is it possible this happened with .NET Core SDK 3.1, because C# source generators just kinda don't do anything if you have them set up in the csproj and build the project with an old SDK. (At least, that's been my experience with mine. I suppose maybe you can grab a newer compiler from a nuget package and make it work with an old .NET SDK.) Maybe the source generator should add some kind of sentinel class/attribute to show it ran, then the Godot tooling can detect it and tell the user (and add some info that'll make it easier to diagnose these issues)? |
How would I know which .NET SDK is being used? |
You can open a terminal in the project folder and run But, Posting your logs would help reduce the guesswork, if you can. Also feel free to wait for @neikeq, I'm not completely sure I'm right about needing a 5.0 version. 😅 |
Yes, you do need .NET 5 Sdk. I think the MSBuild version needed (the one that comes with this Sdk version) is 16.8.0, but I'm not sure. |
Alright that solves it. Thank you! |
Godot version:
I've built Godot myself and I'm currently on master branch bc29f4b
OS/device including version:
I'm on a Macbook x86 running Catalina and using Mono 6.12.0.114.
Issue description:
The Godot application is unable to find the class defined in my script.
I've been debugging the issue using CLion and I think my assembly is missing the AssemblyHasScripts attribute. I think that my class should be loaded in this function
CSharpLanguage::lookup_scripts_in_assembly() (csharp_script.cpp line 1198)
. but it doesn't get through the if statement there. I've tried setting the attribute on my assembly myself by adding this to my csproj<AssemblyAttribute Include="Godot.AssemblyHasScripts" />
but that doesn't work.After that it can't load my script in
CSharpScript::reload()
because the script was never added to thedotnet_script_lookup_map
.Steps to reproduce:
Create a new C# script in the Godot editor and write in some print statement.
Press Play current scene.
The error is visible in the Debugger. "Cannot instance script because the class 'NewScript' could not be found. Script: 'res://NewScript.cs'"
Minimal reproduction project:
My testing project: Master1.zip
The text was updated successfully, but these errors were encountered: