Open Laurnz opened 2 months ago
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?
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.
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.
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:
Stride.GameStudio.exe
(eg. C:\Users\[USER]\.nuget\packages\stride.gamestudio\4.2.0.2188\lib\net8.0-windows7.0
)Stride.GameStudio.runtimeconfig.json
in Notepad (or whatever text editor)"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:
Stride.Core.Assets.CompilerApp.exe
(eg. C:\Users\[USER]\.nuget\packages\stride.core.assets.compilerapp\4.2.0.2188\lib\net8.0
)Stride.Core.Assets.CompilerApp.runtimeconfig.json
in Notepad (or whatever text editor)"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.
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)?
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
?
Thanks, I got it to work, made a stupid mistake. Great workaround. It also seems to be only needed for the Stride.GameStudio
.
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:
The project might also require a framework reference
<FrameworkReference Include="Microsoft.AspNetCore.App"/>
.Screenshots
Log and callstacks Due to another bug, I can not copy the content from the log window.