-
-
Notifications
You must be signed in to change notification settings - Fork 21.6k
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
Can't get method on CallableCustom "Delegate::Invoke" error when building/debugging .NET project #70026
Comments
Just wanted to chime in and say that I am also facing this issue and it's blocking. I'm using the official build of beta 9. Not complaining or anything, I know it's beta :). Is this related to, but not fixed by #69194? If so, do we know how to work around it for the time being? |
Just wanted to provide some more context: This issue occurs for me only when a C# script marked as Here is the code that causes the error, in my case: [Tool]
public partial class LevelManager : Node3D
{
public override void _Ready()
{
LoadBlocks();
if(_levelNode == null){
_levelNode = new Node3D() {Name = "Level"};
AddChild(_levelNode);
if(Engine.IsEditorHint()){
_levelNode.Owner = this;
}
}
LoadLevel();
}
private void LoadBlocks(string path = "Prefabs/Blocks"){
_blockList.Clear();
var files = Directory.GetFiles(path, "*.tscn", SearchOption.AllDirectories);
foreach(String file in files){
var filename = Path.GetFileNameWithoutExtension(file);
_blockList[filename] = GD.Load<PackedScene>($"res://{path}/{filename}.tscn");
}
}
} If either the |
I was running into this. In my case it seems to have been caused by using a .NET 7 SDK instead of .NET 6. {
"sdk": {
"version": "6.0.404"
}
} Currently running Godot 4 Beta 10 on MacOS Ventura 13.0.1. |
This unfortunately hasn't fixed it in my case. On the next build after launching I get the same error as above.
I'm running: dotnet --info shows: |
@gallsy can you confirm that you are running a |
@matthew798 yes that's right.
The only external dependency I'm using is Newtonsoft.Json. |
Been hit by this myself in beta 9.0 I had some [Tool] scripts, but removing [Tool] did not fix the issue. It appears to be being caused by assemblies not getting unloaded properly. From the godot console:
The deluge of errors starts immediately thereafter. In my case, I can cause this to happen by:
Curiously, only building from visual studio code (as opposed to the godot editor) sees the issue with TryReloadRegisteredScriptWithClass and generic classes kick off immediately. The second time you build from VSCode, either the deluge begins in the godot editor or it just outright freezes, but so long as you don't need to edit scenes you can still work and run the project just fine from visual studio code. |
Quick update, I've had some luck tracking this down! The cause - in my case - appeared to be, as the 'failed to unload assemblies' message mentioned, strong GC handles. Specifically, static variables that would persist between reloads and potentially have handles to things that should have been deleted. The quick tl;dr, manage your static variables responsibly. I had a few things static that really didn't need to be, and after refactoring I can no longer reproduce the error as I mentioned previously. |
@guessy42 Interesting. I'd be curious to see what the before and after of your refactoring look like. I don't see how a static variable would cause an issue here. Also, I don't have any static variables in my script. |
It could also be static events, or really anything that creates a strong handle that stops the assembly from being unloaded. To be honest, I'm not 100% sure what all the possible causes for stopping assemblies unloading even are. This is the original, problematic script: https://pastebin.com/Ey7XQtGH It's pretty much moving static variables to singleton instance variables and adding more cleanup / safeguards. Awaiters is an autoload. In hindsight the use of static variables in that script was honestly bound to cause problems but, well, that's hindsight. |
I don't know if my circumstances match everyone else's, but I am seeing this issue in beta 16 as well. I have found that if I hit "Build" manually before hitting the play button I do not seem to get the errors. Also, I noticed that if I do not hit "Build" before hitting play, even if I have mistakes in my code that should prevent compile it still runs the app. I do not need to hit "Build" every time before I hit play if I have not made code changes. I suspect there is an issue causing the build to either not happen or not complete in time when you just press play. As a note, this holds true whether I am compiling for .net6.0 or .net7.0 |
@TomNCatz I was having the same problem with a project that worked in beta 15 but not 16, I was able to fix it (in beta 17) by deleting the "temp" folder at "Project Dir"/.godot/mono/ |
Running 4.0 beta 17 mono edition, ran into the same issue, this solution also worked for me. |
I am now on version rc.3, after deleting the temp folder, the issue would still occur after some code changes and rebuilding. |
I'm also getting this in RC.6, happens quite randomly (but frequent) when building (or playing) |
This still happens in stable. It happens almost every single time I make a change to a C# script, no matter how simple the project is. |
I found a temporary solution. Do not use .Connect(EditorSelection.SignalName.SelectionChanged, new Callable (this, DevHelper.MethodName.XXX)) |
I am also facing this problem in 4.0 Stable. The MRP is simply setting and using any static fields in a Godot-based class's static constructor. My temporary solution is to make sure all static fields and properties are not be set in ModuleInitializer and static constructors of any classes that extends Godot classes, such as Node, Control, etc.. EDIT: |
Does anyone here have an MPR for their way of causing the assembly to fail to unload? |
@RedworkDE It happens pretty much in any project for me once I make a single change to a C# script, but here's a really simple project: Here's a short video on how I can trigger it: godot4.mp4 |
Can't reproduce with that project, but the issue seems to limited to just the error spam, so that probably gets fixed by #75533 already. |
It's not just log spam for me unfortunately. If I run the project one more time without restarting once the errors come up all script export variables will be reset to 0 in the editor which is a massive pain to resolve on larger projects. |
You can try building from source with that PR and test if it fixes the issue problems for you, because the error spam is really just a symptom of the editor breaking beyond recovery and that is what the PR fixes. If it does not (I never tried to figure out what exactly the consequences of continuing are) a lot more system information is need to even begin diagnosing these issues. |
@RedworkDE Just tried the PR and it seems like it does indeed resolve the issue. I get this error now after every change in the C# project but it doesn't seem to affect anything:
|
After loading the plugin, click the arrow position on the screenshot. Then using #75533 will cause other problems. |
I updated to the 4.1 beta 1 and I'm still getting this issue. It's really preventing me from making progress. It happens very reliably for me. Basically I have the game running and then reload the scene twice and I'm locked out basically. However I have to delete the projects .godot folder in the project before reopening the editor to fix the issue. I'm on Fedora Silverblue 38, with VS Code. I haven't got any [Tool]s. After the first reload (Step 4): Details
public abstract partial class Presenter<M, V> : MarginContainer where M : Resource where V : class {}
public partial class FundsPresenter : Presenter<FundsModel, FundsView> {}
public partial class IdeaListPresenter : ArrayPresenter<IdeaListModel, IdeaModel> {}
etc. Then I get this error on repeat on the second reload (Step 6):
I don't mind providing my entire project if it helps diagnose the problem, though it's quite messy. It just takes commenting and uncommenting a line to cause the issue. I'll do some more research and see if I can simplify the reproduction. Edit: Well I created a simple reproduction. Let me get a write up of it and tidy it up then I'll post it. Here it is, there's a readme in the project: |
@dannymate In my case the issue in your reproduction appears in 4.1 beta 1, but running in 4.0 stable or 4.0.3 stable doesn't cause the issue for some reason. I guess 4.1 beta changes something? I also having this issue in my own project that appears in 4.0 stable and in 4.1 beta 1. |
Well from what I gather it seems the first error, with the dictionary entries, is related to ScriptManagerBridge.cs line 579 in which it tries to add the Type which is loaded from an assembly to a ScriptTypeBiMap object. Inside the ScriptTypeBiMap it tries to add the Type as a key but it seems duplicated. I'm not sure why it's Presenter<FundsModel, FundsView> instead of FundsPresenter for example but it seems how it figures out the Type may be part of the problem. Another thing that could help is adding checking for duplicated keys in ScriptTypeBiMap before adding to dictionary or using TryAdd. I'm working off the assumption that the second error is a direct byproduct of the first error. Edit: Unsure if this TODO is related: https://github.com/godotengine/godot/blob/37d1dfef9d81aade27ab0c56fc6b6f12f6a08045/modules/mono/glue/GodotSharp/GodotSharp/Core/Bridge/ScriptManagerBridge.types.cs#LL20C1-L21C1 |
I'm experiencing the same problem in 4.0.3 stable and I have had this problem in previous versions (of Godot 4) as well. It even happens if I have an empty scene set as the main scene with nothing else (no scripts whatsoever) attached to it. Sometimes it happens when I start a new project. And sometimes I make a change to my C# class (just anything, really) and suddenly I'm getting that same repeating error and I have to restart Godot to make it disappear (only for it to come back when I hit play). |
this problem is present in version 4.0.3 of c#. problem is stable. |
Tested my project and MRP in 4.1 and still getting this issue. There are some slight differences and improvements however.
Overall still a big issue for me and is getting in the way of developing my game. |
I have this problem too with my C# game+plugin project since 4.0 (but it got worser in 4.1). Before i just ignored it and it worked. But now in 4.1, when i build my project in Visual Studio, Godot starts to drop ".NET failed to unload assemblies" and |
Godot version
4.0beta
System information
windows10,NVIDIA GeForce GTX 1660,Vulkan API 1.2.0
Issue description
GODOT BETA 7.0 C # version, when debugging for many times, suddenly stuck, the debugging progress bar did not respond, and then if the program was not forced to close in time, the entire operating system would crash.
But there is no error prompt,
After I restart the computer, a lot of errors will occur when I open the project:
Deleting the godot folder can solve the problem, but it will seriously affect my computer health and my spirit.
I'm going crazy.
Please solve this problem, otherwise it will become difficult to use, thank you.
Steps to reproduce
N/A
Minimal reproduction project
N/A
The text was updated successfully, but these errors were encountered: