Godot Version
Godot_v4.6.3-stable_mono_win64.exe
Godot_v4.7.0-stable_mono_win64.exe
Question
I’m using Godot.FileAccess.GetAsText() to read in a data file (highscores) and it works just fine when I run the game from Godot. However, when I run from Visual Studio using “Debug With Godot” option, everything works just fine EXCEPT this one call. I’m trying to debug some other functions of my HighScore screen and need to load this data, but for some odd reason it won’t run.
Cannot find that this is a known issue and thus no workaround.
I first open the dataFile:
var dataFile = FileAccess.OpenEncryptedWithPass(_dataFilePath, FileAccess.ModeFlags.ReadWrite, “password");
var highScores = dataFile.GetAsText(); ← ERROR HERE
The error shown in Visual Studio Debugger is:
**System.MissingMethodException: ‘Method not found: ‘System.String Godot.FileAccess.GetAsText()’.’
**
Again, loads and saves just fine when running from Godot… just not in VS Debugger.
Ideas?
ETA: Tested with 4.7.0 as well. No dice.
Is the file part of the project? If so it may be a path issue. You may have to supply the absolute path for the file.
you can insert the following
var path = ProjectSettings.GlobalizePath(“res://”);
If path is an empty string then the code is not being executed in Godot editor. So you’ll have to likely append the relative path used in Godot
var path = ProjectSettings.GlobalizePath(“res://”);
if (path == String.Empty)
{
// code not running in editor get base path
path = OS.GetExecutablePath().GetBaseDir();
//do something here to fix to path to point to the data file
}
Thanks for the suggestion, but it’s not finding the function – nothing to do with the parameters being passed in. And the opening the file works as expected (as does writing out the file). It’s the one function GetAsText() that’s not being found. :(
This almost looks like the debugger is not set up correctly, or something with Visual Studio isn’t set up right.
How did you set up debugging and overall your C# workflow?
Now that I think about it, it could also be a version mismatch. Can you somehow confirm that the godot VS launches is the exact same version that you’re working in?
Yes, they are the correct versions. Was 4.6.3 and is now 4.7.0.
Oddly, I commented out the line that calls .GetAsText() and was able to step into the code… the error quoted above actually raises before going into the method. So commenting out that line, it steps into the method correctly.
So after opening the file, I hit a breakpoint and in Immediate Mode, called the .GetAsText() function to load the result into the variable and it worked just fine and was able to continue with no issues.
Odd that it won’t work otherwise as a direct call.
This almost looks like the debugger is not set up correctly, or something with Visual Studio isn’t set up right.
We have a winner!
I first created my project on an older machine. I had the debug configuration setup to use Godot 4.5.1 as the exe, even though the project was using Godot 4.6.3/4.7.0 (both engine and Nuget). So when I launched the Debug with Godot configuration, it was running the newer code against the 4.5.1 engine. I corrected that and voila… the method is now found. I guess .GetAsText() was not around in 4.5.1? Dunno, but it now works. Thanks!