Godot: C# - Failed to build project solution/library out of sync?

Created on 2 Feb 2018  路  18Comments  路  Source: godotengine/godot

Godot version:
3.0 stable

OS:
Windows 10 x64

Issue description:
When I try to run a C# project, I get a build error saying "Failed to build project solution". When I delete the .mono folder and hit run, godot says "failed to build GodotSharp solution". I hit run again and it says "failed to build GodotSharpEditor solution". I hit run once again and I'm back at getting the "failed to build project solution" error again.

The Godot console says (twice):
"Your mono runtime and class libraries are out of sync.
The out of sync library is: C:\Program Files\Mono\lib\/mono/4.5/mscorlib.dll

When you update one from git you need to update, compile and install
the other too.
Do not report this as a bug unless you're sure you have updated correctly:
you probably have a broken mono install.
If you see other errors or faults after this message they are probably related
and you need to fix your mono install first."

"ERROR: The build method threw an exception.
System.MissingMethodException: Attempted to access a missing method.
At: modules\mono\editor\godotsharp_builds.cpp:488"

The mscorblib.dll is where it's supposed to be, according to the path. I don't know if it's because the two "\/" slashes in the path, because I couldn't find anyone else having this issue and it would be more common if that'd be it.
I've tried it with multiple mono versions (msi) ranging from the earlierst 5.4 to 5.8.108

When opening the Script in Visual Studio Code its output says:
"[fail]: OmniSharp.MSBuild.ProjectFile.ProjectFileInfo
The reference assemblies for framework ".NETFramework,Version=v4.5" were not found. To resolve this, install the SDK or Targeting Pack for this framework version or retarget your application to a version of the framework for which you have the SDK or Targeting Pack installed. Note that assemblies will be resolved from the Global Assembly Cache (GAC) and will be used in place of reference assemblies. Therefore your assembly may not be correctly targeted for the framework you intend."

These two mono logs were created when testing it again:
1517588347.txt
1517588338.txt

Saying something about *.dll.dll ?

Steps to reproduce:


    • New Project


    • Add any Node


    • Attach C# script


    • Save scene and run

What I have tried:

  • Different mono versions
  • Update .NET Framework
  • Deleting godot user data in %appdata%
  • Running the project with a shell script ("pathto\Godot_v3-stable_mono_win64.exe Main.tscn" (as task in VS Code)), which runs the game, but doesn't execute any c# code
  • Looking for wrong paths
bug windows mono

Most helpful comment

it seems that the mono-2.0-sgen.dll version distributed is not compatible with the latest mono

I made it work, compiling Godot from sources with mono enabled, , it generated the "mono-2.0-sgen.dll" and i just copied that .dll overriding the one distributed , or just using the compiled one, you can see how to compile in this video

https://www.youtube.com/watch?v=WftO7GnWCHA

All 18 comments

I've got it partially working now. I downgraded to Mono 5.4.1 (5.4.1.7-x64-0 to be exact) and now c# scripts do work and the project runs fine. I've tried 5 different mono versions, including the latest 5.8, but 5.4.1 is the first version that worked.

Except for deleting the .mono folder in the project and the mono folder located in %appdata%->Godot, I did nothing else between switching Mono versions.

VS Code has still no code completion and says:
"[fail]: OmniSharp.MSBuild.ProjectFile.ProjectFileInfo
The reference assemblies for framework ".NETFramework,Version=v4.5" were not found. To resolve this, install the SDK or Targeting Pack for this framework version or retarget your application to a version of the framework for which you have the SDK or Targeting Pack installed. Note that assemblies will be resolved from the Global Assembly Cache (GAC) and will be used in place of reference assemblies. Therefore your assembly may not be correctly targeted for the framework you intend.
Failed to load project file 'c:\Development\Projects\CSTest2\CSTest2.csproj'.
c:\Development\Projects\CSTest2\CSTest2.csproj"

This test project was created after I got it running with the 5.4.1 Mono version.
According to my registry, my net framework is version 4.7

it seems that the mono-2.0-sgen.dll version distributed is not compatible with the latest mono

I made it work, compiling Godot from sources with mono enabled, , it generated the "mono-2.0-sgen.dll" and i just copied that .dll overriding the one distributed , or just using the compiled one, you can see how to compile in this video

https://www.youtube.com/watch?v=WftO7GnWCHA

Thanks @hgouveia , I've tried compiling from source with the same results as in my previous post. The game runs and the code works, but there is no Code-Completion in VS Code (c# extension is installed) nor in the in-engine script editor. Unfortunately I don't know how to debug these things properly and I'm running out of ideas.

Regarding the VS Code error I posted earlier, the common fix seems to be updating mono, but then the projects won't run anymore and bring me back to my initial issue of "faild to build X soltion"...

@Dieselpirat that happened to me too, remove all mono versions, install latest mono again, install .NET core SDK and Python 2.7 too , restart your pc, compile the engine following the video , or just this instruction

on your godo sources folder run this commands

pip install --egg scons

"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" amd64

git pull

# Generate first a godot tool to generate the godot biding for mono

scons platform=windows target=release_debug tools=yes verbose=yes progress=yes module_mono_enabled=yes mono_glue=false

cd bin

godot.windows.opt.tools.64.mono.exe --generate-mono-glue ../modules/mono/glue

# Generate the final build with mono

cd ..

scons platform=windows target=release_debug tools=yes verbose=yes progress=yes module_mono_enabled=yes

Create a new proyect, dont use old ones, and try again, remeber to set the Editor in Godot to use VSCode

hey @hgouveia , feel like posting the dll on dropbox? already spent 6 hours to get it to work and compiling all of it is too much right now :)

@hgouveia you are the hero of the day, thank you!

@hgouveia Thanks, you are indeed the hero of the day! :D

I've removed and reinstalled the latest Mono and compiled Godot from source using Visual Studio 2015, Python 2.7.14 and scons 3.0.1, which went flawlessly.

@Dieselpirat @kimswe no problem guys and as a bonus in case you are interested, here is my tasks.json for vscode to run and compile, https://gist.github.com/hgouveia/134f4007e9ed65aafad76e5808f7f543

Well, sounds like we need to ship the Mono SDK on Windows too @neikeq, since it apparently wants the exact same version for the mscorlib.dll we ship and the rest of the SDK.

I think shipping mscorlib should be enough.

This should be fixed by #15641.
Let us know if you can still reproduce this after 3.0.2 is released.

@akien-mga @neikeq Quick feedback: I've just tried Godot_v3.0.2-rc1_mono_win64 and the latest stable Godot_v3.0.1-stable_mono_win64 for comparison. 3.0.1 still fails to build solutions for me, but the 3.0.2-rc1 definitely works!
I've rebuild multiple small projects and had no issues using the rc1, which means this fixed it on my end! Thanks guys! 馃憤

Awesome, thanks for testing and reporting back!

Actually, in order to test it you would need to build Godot against Mono 5.4 and then run it with a Mono 5.8 or higher install (those are the versions I could reproduce this with), or simply wait for 3.0.2 to be released.

The bug happened because:

  • We build Godot against Mono 5.4, and we ship Godot with the Mono runtime for that version.
  • The class System.Threading.WaitHandle from mscorlib.dll that comes with Mono 5.8 makes use of an internal call to the runtime called Wait_internal.
  • Wait_internal was added to the runtime at some point after 5.4, so mscorlib from newer versions (like 5.8) will not find it in the Mono 5.4 runtime, and you get a MissingMethodException.

The solution is to simply ship with mscorlib so both it and the runtime we bundle have the same version.

I've been looking at the mono repo, and it seems the only assembly other than mscorlib that depends on a good amount of internal calls is System.dll, so we may need to ship that one as well in the future if we get "out of sync" issues.

or simply wait for 3.0.2 to be released.

Well they tested against 3.0.2-rc1, so there's that :)

Oh, I thought he built from source.

@neikeq I have tried 3.0.2-rc1 and it failed to build GodotSharp solution, same problem :(

Was this page helpful?
0 / 5 - 0 ratings