Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Game Studio crashes when loading HTTP abstractions #2445

Open
Laurnz opened this issue Sep 13, 2024 · 7 comments
Open

Game Studio crashes when loading HTTP abstractions #2445

Laurnz opened this issue Sep 13, 2024 · 7 comments
Labels
bug Something isn't working

Comments

@Laurnz
Copy link

Laurnz commented Sep 13, 2024

Release Type: Official Release installed with the Stride launcher

Version: 4.2.0.2188, but also older

Platform(s): Windows

Describe the bug
When the Game Studio opening a solution containing an async method returning Task<IResult>, it will crash.

To Reproduce
Include this code somewhere in a Stride project and open the solution with the Game Studio:

async Task<IResult> Test()
{
    return null;
}

The project might also require a framework reference <FrameworkReference Include="Microsoft.AspNetCore.App"/>.

Screenshots
image

Log and callstacks
Due to another bug, I can not copy the content from the log window.

@Laurnz Laurnz added the bug Something isn't working label Sep 13, 2024
@Kryptos-FR
Copy link
Member

Kryptos-FR commented Sep 13, 2024

On which project is this reference defined, is it on the executable project or on the library one?

Does it fix it, if the mentioned library is explicitly referenced in the .csproj?

@Laurnz
Copy link
Author

Laurnz commented Sep 16, 2024

I tried referencing it in all projects, it made no difference.

It also crashes if the code snippet is inserted in any referenced project. The only case it does not hinder Stride Studio from loading is, when it is used in the platform specific projects like MyGame.Windows, but I need the code to be in an extra referenced project.

@Basewq
Copy link
Contributor

Basewq commented Sep 16, 2024

This sounds similar to the CompilerApp + WPF reference issue a while back.

Stumbling on this stackoverflow issue, it seems like a tough issue to solve.
Basically any FrameworkReference referenced by the user's library also needs to be referenced by the "loader" (ie. GameStudio and/or CompilerApp) in order to allow Assembly.Load to work (which is what Stride's doing).
Unfortunately I can't find any links with any real solutions here.

@Basewq
Copy link
Contributor

Basewq commented Sep 16, 2024

Ok, I think I discovered the very clunky workaround, as per https://learn.microsoft.com/en-us/dotnet/core/runtime-config/
which involves modifying the [appname].runtimeconfig.json files.
Basically force the exe to load the FrameworkReference by adding it to the config.

Make sure to backup the json files before modifying them!

For the Editor:

  1. Locate Stride.GameStudio.exe (eg. C:\Users\[USER]\.nuget\packages\stride.gamestudio\4.2.0.2188\lib\net8.0-windows7.0)
  2. Open Stride.GameStudio.runtimeconfig.json in Notepad (or whatever text editor)
  3. Add the appropriate FrameworkReference dependency, in this case "Microsoft.AspNetCore.App", so your file should now look something like:
  "runtimeOptions": {
    "tfm": "net8.0",
    "frameworks": [
      {
        "name": "Microsoft.NETCore.App",
        "version": "8.0.0"
      },
      {
        "name": "Microsoft.WindowsDesktop.App",
        "version": "8.0.0"
      },
      {
        "name": "Microsoft.AspNetCore.App",
        "version": "8.0.0"
      }
    ],
    "configProperties": {
      "System.Reflection.Metadata.MetadataUpdater.IsSupported": false,
      "System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization": true
    }
  }
}

For the CompilerApp:

  1. Locate Stride.Core.Assets.CompilerApp.exe (eg. C:\Users\[USER]\.nuget\packages\stride.core.assets.compilerapp\4.2.0.2188\lib\net8.0)
  2. Open Stride.Core.Assets.CompilerApp.runtimeconfig.json in Notepad (or whatever text editor)
  3. Add the appropriate FrameworkReference dependency, in this case "Microsoft.AspNetCore.App", so your file should now look something like:
  "runtimeOptions": {
    "tfm": "net8.0",
    "frameworks": [
      {
        "name": "Microsoft.NETCore.App",
        "version": "8.0.0"
      },
      {
        "name": "Microsoft.AspNetCore.App",
        "version": "8.0.0"
      }
    ],
    "configProperties": {
      "System.Reflection.Metadata.MetadataUpdater.IsSupported": false,
      "System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization": false
    }
  }
}

Note this one had "framework", but now we're changing it to "frameworks" (plural),

Unfortunately you'll have to do this for every new version that comes out if you decide to update your Stride version.

@Laurnz
Copy link
Author

Laurnz commented Sep 16, 2024

The fix with the runtimeconfig.json is not working for me. Did you also try it out?

Some interesting things about this problem. I can also use the (deprecated) NuGet version of the framework with <PackageReference Include="Microsoft.AspNetCore.App" Version="2.2.8" />. It is also displaying the same error, but I don't know if it is maybe still using it as a framework reference in the background.

It also makes a difference if it is async or not. I can use the framework with its classes and methods, as long as my method signature that returns the something from the framework is not async.

And why does it happen, if that code is in some other referenced project (in the same solution)?

@Basewq
Copy link
Contributor

Basewq commented Sep 16, 2024

The fix with the runtimeconfig.json is not working for me. Did you also try it out?

I did before I posted, and tried again before posting this reply.
I removed the "name": "Microsoft.AspNetCore.App" from the Stride.GameStudio.runtimeconfig.json and got your error.
Added it back and it opened ok.

Not sure why it's working for me but not yours.
I am only adding the <FrameworkReference Include="Microsoft.AspNetCore.App"/> to the csproj and the async Task<IResult> Test() code. Maybe there's some additional references that's needed as well.

EDIT: maybe double check you also have a version 8 of Microsoft.AspNetCore.App installed in your C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App?

@Laurnz
Copy link
Author

Laurnz commented Sep 16, 2024

Thanks, I got it to work, made a stupid mistake. Great workaround. It also seems to be only needed for the Stride.GameStudio.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants