Skip to content

can_instantiate: Cannot instance script because the associated class could not be found. Script: 'res://testClass.cs'. Make sure the script exists and contains a class definition with a name that matches the filename of the script exactly (it's case-sensitive). #71735

Description

@FelipeRattu

Godot version

4.0 Beta 13 Mono

System information

Windows 10 Pro 22H2

Issue description

This issue proves that #66419 is still not fixed

I'm using Godot 4 Beta Mono and for some reason some projects glitch and keep showing me this error (title of the issue). I've decided to make a test project to reproduce it and couldn't find a way to do it, so i just duplicated a project i had and wiped all the files in it in order to create a single scene with a single script called testClass.cs, and this way i could reproduce it but what causes it to happen is unknown to me. Here's the content of the script:

using Godot;
using System;

public partial class testClass : Node2D
{
	// Called when the node enters the scene tree for the first time.
	public override void _Ready()
	{
	}

	// Called every frame. 'delta' is the elapsed time since the previous frame.
	public override void _Process(double delta)
	{
	}
}

the class name matches the file name and the script is in the right path, it even opens on VSCode (which i'm using for the project as the main editor). I've also noticed after messing with other non glitched projects that the ones that are glitched do not allow me to open any file in the OS file system by right clicking and selecting the option:

image

Whenever i click this option on a glitched project it just does nothing, while in other projects (in the same version of Godot and using C# and VSCode as well) it just normally opens the OS file system and shows the project as expected.

Changing the project to another folder, erasing the .godot folder and trying to re-open in the editor and reload the files do not solve it, once a project get this glitch it'll be it, at least in my experiences and tests. Even deleting the entire project and recloning it (in case it's a project on github) does not solve the problem.

Tried it in a 3.x version and couldn't replicate the bug.

Steps to reproduce

Just create a project, a main node and a C# script in Godot 4.0 Beta 13 Mono (i had the same issue in Beta 9 forward so any of those might have that too) and see if it happens, the exact steps are unclear since i tried adding more scenes, scripts, folders and everything to another test project and it didn't happened. Luckly i have a minimal reproduction project that have this problem, be aware that this problem might not happen on Linux or any Windows version besides 10.

Minimal reproduction project

Just open it an run with F5

Minimum reproduction project.zip

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status
    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions