godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
89.09k stars 20.2k forks source link

[Mono] Conversion of MonoString to UTF8 failed #19483

Closed TritiatedWater closed 5 years ago

TritiatedWater commented 6 years ago

Godot version: 257d3c3f39fd144d202f112c9cb08a82c174afbc

OS/device including version: Ubuntu Linux 18.04

Issue description: I'm trying to get a bool from my settings file. But it gives me:

0:00:00:0847 - Conversion of MonoString to UTF8 failed.
----------
Type:Error
Description: Conversion of MonoString to UTF8 failed.
Time: 0:00:00:0847
C Error: Method/Function Failed, returning: p_default
C Source: core/io/config_file.cpp:90
C Function: get_value

Steps to reproduce:


config.SetValue("Display", "Fullscreen", false);
config.Save("user://settings.cfg");
if ((bool)config.GetValue("Display", "Fullscreen") == true) {
                 OS.SetWindowFullscreen(true);
        } else {
                 OS.SetWindowFullscreen(false);
        }
aaronfranke commented 6 years ago

I'm getting the same error with Godot 3.0.4. I'm on Xubuntu Linux 18.04 with Mono 5.12. Code:

GD.Load("res://Assets/Menu/UI/MenuTheme.tres")

Error:

0:00:01:0599 - Conversion of MonoString to UTF8 failed.
----------
Type:Error
Description: Conversion of MonoString to UTF8 failed.
Time: 0:00:01:0599
C Error: Method/Function Failed, returning: RES()
C Source: core/io/resource_loader.cpp:186
C Function: _load
TritiatedWater commented 6 years ago

CC @neikeq

lordee commented 6 years ago

I'm also getting this, on something I otherwise do right above it:

Button _joinBtn;
    Button _hostBtn;
    Network _network;
    public override void _Ready()
    {
        _joinBtn = (Button)GetNode("panel/join");
        _hostBtn  = (Button)GetNode("panel/host");
        _network = (Network)GetNode("/root/OpenFortress/Network");

Fails on finding/assigning network.

neikeq commented 5 years ago

I cannot reproduce this. Does this always happen or only some times?

Can you try replacing these two lines: https://github.com/godotengine/godot/blob/3e128a6d8aa2982ec4da20c1dd73faa968b9207a/modules/mono/mono_gd/gd_mono_marshal.cpp#L195-L196

with:


    if (!mono_error_ok(&error)) {
        ERR_PRINTS(String("Failed to convert MonoString* to UTF-8: ") + mono_error_get_message(&error));
        ERR_FAIL_V(String());
    }

and paste the new error message here?

TritiatedWater commented 5 years ago

Hmm, the error doesn't happen anymore on c3023e8. I don't know why.

akien-mga commented 5 years ago

Closing as fixed as per the above.