Repository: godot
Issue: Export that had, but no longer has, C# scripts fails
Labels: bug,topic:dotnet,topic:export

### Godot version

v3.4.2.stable.mono.official [45eaa2daf]

### System information

Gentoo Linux x86-64

### Issue description

```
$ ./linux 
Godot Engine v3.4.2.stable.mono.official.45eaa2daf - https://godotengine.org
OpenGL ES 2.0 Renderer: NVIDIA GeForce GTX 960/PCIe/SSE2
OpenGL ES Batching: ON
 
Mono: Log file is: '/home/<elided>/.local/share/godot/app_userdata/Test Project/mono/mono_logs/2022-01-13_08.47.52_8157.log'
ERROR: Failed to load one of the API assemblies.
   at: _load_api_assemblies (modules/mono/mono_gd/gd_mono.cpp:944)

=================================================================
	Native Crash Reporting
=================================================================
Got a UNKNOWN while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries 
used by your application.
=================================================================

=================================================================
	Native stacktrace:
=================================================================
	0xacfa3d - ./linux : 
	0xacfdc9 - ./linux : 
	0xac259f - ./linux : 
	0xad9a20 - ./linux : 
	0x7f1a8f32a120 - /lib64/libpthread.so.0 : 
	0xd7e016 - ./linux : _ZN6GDMono26initialize_load_assembliesEv
	0x2524a2f - ./linux : _ZN12ScriptServer14init_languagesEv
	0xd4cb30 - ./linux : _ZN4Main6setup2Em
	0xd51dd3 - ./linux : _ZN4Main5setupEPKciPPcb
	0x9f57a9 - ./linux : main
	0x7f1a8f0f05fd - /lib64/libc.so.6 : __libc_start_main
	0x9f6ede - ./linux : 

=================================================================
	Telemetry Dumper:
=================================================================
Pkilling 0x139751346927168x from 0x139752044447552x
Entering thread summarizer pause from 0x139752044447552x
Finished thread summarizer pause from 0x139752044447552x.
Failed to create breadcrumb file (null)/crash_hash_0x0
Could not exec mono-hang-watchdog, expected on path '/tmp/data_Test Project/Mono/etc/../bin/mono-hang-watchdog' (errno 2)

Waiting for dumping threads to resume

=================================================================
	External Debugger Dump:
=================================================================
[New LWP 8158]
[New LWP 8161]
[New LWP 8162]
[New LWP 8163]
[New LWP 8164]
[New LWP 8165]
[New LWP 8166]
warning: Could not load vsyscall page because no executable was specified
0x00007f1a8f1881b7 in ?? ()
  Id   Target Id              Frame 
* 1    LWP 8157 "linux"       0x00007f1a8f1881b7 in ?? ()
  2    LWP 8158 "linux"       0x00007f1a8f32c00a in ?? ()
  3    LWP 8161 "linux"       0x00007f1a8f32c00a in ?? ()
  4    LWP 8162 "linux"       0x00007f1a8f1836b5 in ?? ()
  5    LWP 8163 "linux"       0x00007f1a8f1836b5 in ?? ()
  6    LWP 8164 "linux"       0x00007f1a8f1b1b51 in ?? ()
  7    LWP 8165 "SGen worker" 0x00007f1a8f32c00a in ?? ()
  8    LWP 8166 "Finalizer"   0x00007f1a8f32c00a in ?? ()

Thread 8 (LWP 8166 "Finalizer"):
#0  0x00007f1a8f32c00a in ?? ()
#1  0x0000000000000001 in ?? ()
#2  0x00007f1a00000189 in ?? ()
#3  0x0000000003313b00 in ?? ()
#4  0x0000000000000000 in ?? ()

Thread 7 (LWP 8165 "SGen worker"):
#0  0x00007f1a8f32c00a in ?? ()
#1  0x0000000000000000 in ?? ()

Thread 6 (LWP 8164 "linux"):
#0  0x00007f1a8f1b1b51 in ?? ()
#1  0x00000000068ca3c0 in ?? ()
#2  0x00007f1a65f23cc0 in ?? ()
#3  0x0000000500000000 in ?? ()
#4  0x00007f1a65f23d30 in ?? ()
#5  0x0000000000000000 in ?? ()

Thread 5 (LWP 8163 "linux"):
#0  0x00007f1a8f1836b5 in ?? ()
#1  0x0000001900000000 in ?? ()
#2  0x0000000066724d20 in ?? ()
#3  0x00007f1a66724c80 in ?? ()
#4  0x0000000000000000 in ?? ()

Thread 4 (LWP 8162 "linux"):
#0  0x00007f1a8f1836b5 in ?? ()
#1  0x0000000000000000 in ?? ()

Thread 3 (LWP 8161 "linux"):
#0  0x00007f1a8f32c00a in ?? ()
#1  0x0000000000000000 in ?? ()

Thread 2 (LWP 8158 "linux"):
#0  0x00007f1a8f32c00a in ?? ()
#1  0x0000000000000000 in ?? ()

Thread 1 (LWP 8157 "linux"):
#0  0x00007f1a8f1881b7 in ?? ()
#1  0x0000000000000000 in ?? ()
[Inferior 1 (process 8157) detached]

=================================================================
	Basic Fault Address Reporting
=================================================================
Memory around native instruction pointer (0xd7e016):0xd7e006  7e 55 d4 01 48 8d 3d 5c 53 d4 01 e8 3a ab b4 01  ~U..H.=\S...:...
0xd7e016  0f 0b 0f 1f 84 00 00 00 00 00 48 8d 0d 01 b9 d4  ..........H.....
0xd7e026  01 ba a3 03 00 00 48 8d 35 55 55 d4 01 48 8d 3d  ......H.5UU..H.=
0xd7e036  33 53 d4 01 e8 71 24 b5 01 e9 68 ff ff ff 0f 1f  3S...q$...h.....

=================================================================
	Managed Stacktrace:
=================================================================
=================================================================
Aborted
```

The log file named in `mono_logs` is empty. I considered whether this might be GH-32185 or GH-32980, but it didn’t seem like quite the same thing because the former is a crash in a different location and the latter reports a crash happening even in the absence of solution files, while here deleting the solution files fixes the problem (though I haven’t tried Android).

### Steps to reproduce

1. Create a basic project (just a button in a Node2D is sufficient).
2. Attach a C# script.
3. Detach the C# script.
4. Delete the `.cs` file from the project.
5. Attach a GDScript instead.
6. Export the project for Linux/X11.

Note that this leaves the `.csproj` and `.sln` files lying around, even though there is no C# code in the project any more. Deleting those files and reloading the project makes the problem go away, though I don’t see any way to do that step inside the Godot editor itself. The HTML5 export fails with the same basic error, and again is fixed by removing the solution files.

### Minimal reproduction project

[test.zip](https://github.com/godotengine/godot/files/7864501/test.zip)