Godot version:
Godot 3.1
OS/device including version:
Windows 10
Issue description:
Changing Project Settings > Application > Config > Name and running the project gives the error "Cannot instance script because the assembly project is not loaded" to all C# scripts. If you close and open Godot again after this, however, it fixes the issue.
Agree that this happened to me, as well.
Found a temporary fix with some help from @ForLoveOfCats. To rename a project just manually change the name everywhere in your project files. Make sure to check Properties/AssemblyInfo.cs
.
I'm still of the opinion that, at least for now, the generated C# project and related files/properties should just be called GodotProject (or something like that). This would eliminate the issue of a project rename breaking everything since no matter what the project is named it will always be able to find GodotProject.sln and its related files.
My idea was to create an project setting for the csproj name that is filled with the project name the first time it's created, but is not updated if the project name changes.
Is this still reproducible in latest 3.2 builds?
Still reproducible in 3.2 RC 1 Mono. E.g. after renaming the "DodgeTheCreepsCS" demo to "DodgeTheCreeps CS", pressing "Run" starts the game fine but scripts are broken:
ERROR: can_instance: Cannot instance script because the project assembly is not loaded. Script: 'res://Main.cs'.
At: modules/mono/csharp_script.cpp:2892.
ERROR: can_instance: Cannot instance script because the project assembly is not loaded. Script: 'res://Player.cs'.
At: modules/mono/csharp_script.cpp:2892.
ERROR: can_instance: Cannot instance script because the project assembly is not loaded. Script: 'res://HUD.cs'.
At: modules/mono/csharp_script.cpp:2892.
ERROR: emit_signal: Error calling method from signal 'pressed': 'CanvasLayer(HUD.cs)::OnStartButtonPressed': Method not found..
At: core/object.cpp:1228
As mentioned above though, restarting the editor fixes it, so it's not critical to fix for the 3.2 release.
How I fixed this issue was manually editing "old_project_name.sln" and "old_project_name.csproj".
I believe this is case-sensitive, although I haven't tested it.
I believe to fix this when a project is renamed in the mono build these values need to be modified.
Tested on v3.2.2 mono.
Following @tuckersn comment, I used Visual Studio Code to replace all occurence of the old name with the new name.
Use [Ctrl] + [Shift] + F to find all occurence of the old name and replace all of them.
When changing project name, it would be nice to also change the root folder name. But in general, I see there are many files that reference the old project name, so I think it's not simple to implement (I'm new so my perspective is limited).
Most helpful comment
How I fixed this issue was manually editing "old_project_name.sln" and "old_project_name.csproj".
I believe this is case-sensitive, although I haven't tested it.
I believe to fix this when a project is renamed in the mono build these values need to be modified.
Tested on v3.2.2 mono.