QueueFree() causes CS0155 in C#

Godot Version

4.3

Question

As part of my code, I’ve created a placeholder scene that is instantiated, then should be immediately killed.

What I’ve done , is type QueueFree(); in the first line of _Ready in a script attached to the root node of type Node2D.


and the scene tree:
image
Note: ColorRect is irrelevant. The error appears whether it is there or not.

This will generate the compiler error CS0155, and will fail to build, alongside the message;
The type caught or thrown must be derived from System.Exception(30,20)
and will state the file;
C:\Users\[me]\Documents\GitHub\Critical-Damage\Godot.SourceGenerators\Godot.SourceGenerators.GodotPluginsInitializerGenerator\GodotPlugins.Game.generated.cs(30,20)

Can someone smarter than me help fix this, please? :slight_smile:

Maybe the class name Exception means you are trying to expand System.Exception, which is used for the expection processing.

  • Try to change your class name to another one.
4 Likes

Exception is a class name in System. That’s why Exception has the 3 dots beneath it. Hover over those to read suggestions.

You either need to use a namespace:

namespace MyNameSpace;

public partial class Exception : Node
{

or choose a different name for your class. I recommend both.

3 Likes

Hi, thanks for your help, that was it! I’ve changed the name now and it works again. Thank you very much!

Ok, I didn’t realise that’s what the 3 dots meant. Thank you very much for your help, it’s been fixed now! :slight_smile: