madewokherd / wine-mono

Other
294 stars 39 forks source link

Multiple UWP apps crash at start due to missing "Windows.Foundation.UniversalApiContract" #196

Closed Fox2Code closed 4 months ago

Fox2Code commented 4 months ago

Wine bug: https://bugs.winehq.org/show_bug.cgi?id=52092

I know this is dotnet 5+, but dotnet 5 seems to be crashing when running with dotnet 5+

Unhandled Exception:
System.IO.FileNotFoundException: Could not load file or assembly 'Windows.Foundation.UniversalApiContract, Version=7.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies.
File name: 'Windows.Foundation.UniversalApiContract, Version=7.0.0.0, Culture=neutral, PublicKeyToken=null'
  at MinecraftInstaller.App.Main () [0x0007d] in <e46d004a5e4349df92f513ccadd5bbaf>:0 
[ERROR] FATAL UNHANDLED EXCEPTION: System.IO.FileNotFoundException: Could not load file or assembly 'Windows.Foundation.UniversalApiContract, Version=7.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies.
File name: 'Windows.Foundation.UniversalApiContract, Version=7.0.0.0, Culture=neutral, PublicKeyToken=null'

Currently dotnet crashes on wine when running the Minecraft installer.

Extra dlls are available here: https://www.nuget.org/packages?q=WindowsContract

Fox2Code commented 4 months ago

I really think wine would benefit from wine-mono supporting dotnet 5

madewokherd commented 4 months ago

That's a .winmd file. Wine should provide those separately from Wine Mono. No need to replace any part of dotnet 5.

Fox2Code commented 4 months ago

@madewokherd The nuget package doesn't contain any winmd files, thoses are not winmd files.

Maybe you mean the dlls needs the winmd files to work properly?
Wine doesn't support .winmd files yet, but will in the future if given enough interest.

When nothing is done the error message is:

Unhandled Exception:
System.IO.FileNotFoundException: Could not load file or assembly 'Windows.Foundation.UniversalApiContract, Version=7.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies.
File name: 'Windows.Foundation.UniversalApiContract, Version=7.0.0.0, Culture=neutral, PublicKeyToken=null'
  at MinecraftInstaller.App.Main () [0x0007d] in <e46d004a5e4349df92f513ccadd5bbaf>:0 
[ERROR] FATAL UNHANDLED EXCEPTION: System.IO.FileNotFoundException: Could not load file or assembly 'Windows.Foundation.UniversalApiContract, Version=7.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies.
File name: 'Windows.Foundation.UniversalApiContract, Version=7.0.0.0, Culture=neutral, PublicKeyToken=null'

When I move all the required dlls from the nuget packages next to the installer the error message is:

Unhandled Exception:
System.TypeLoadException: Could not resolve type with token 01000046 from typeref (expected class 'System.Runtime.InteropServices.IDynamicInterfaceCastable' in assembly 'System.Runtime.InteropServices, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a')
  at MinecraftInstaller.App.Main () [0x0007d] in <e46d004a5e4349df92f513ccadd5bbaf>:0 
[ERROR] FATAL UNHANDLED EXCEPTION: System.TypeLoadException: Could not resolve type with token 01000046 from typeref (expected class 'System.Runtime.InteropServices.IDynamicInterfaceCastable' in assembly 'System.Runtime.InteropServices, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a')

(See https://github.com/madewokherd/wine-mono/issues/151)

With Microsoft dotnet, it return an error from kernel32 which is out of scope for wine-mono, but what I can say is Microsoft dotnet embed those dlls in some way.

Definitely an update to https://github.com/madewokherd/wine-mono/issues/151

On GitHub there is labels for issues, if you want to support dotnet5.0 making a label for it would be great.

I think either leave both issues open, or close both.
I really would like wine-mono leave both open and experiment with dotnet5.0 but it's not my call to make.

Whatever is decided, please make it clear in the readme, because Wine-Mono stance on it is currently unclear.

Fox2Code commented 4 months ago

This is fine -> https://github.com/madewokherd/wine-mono/issues/15#issuecomment-2107551161

Just found out about this after sending my message, well you could still have changed your mind.

I'll close my other dotnet5+ related issue (https://github.com/madewokherd/wine-mono/issues/151), reopen both issues if you changed your mind.

madewokherd commented 4 months ago

The installer exe for this is .NET 4 and runs in .NET Framework on Windows.

madewokherd commented 4 months ago

Maybe it references types from .NET 5 but the references are unused, and .NET Framework ignores the unused references in this situation while Mono does not?

Fox2Code commented 4 months ago

I think wine-mono and dotnet5 behave similarly enough.

With the GAC, I don't think wine-mono being able to run most dotnet5+ stuff would be an enormous amount of work.

My theory is the MinecraftInstaller is probs declaring itself as dotnet4 while being a dotnet5 application, and it expect dotnet4 to be able load and run dotnet5 libraries?

madewokherd commented 4 months ago

I don't think so, but if that's the case then it should be possible to write a test case demonstrating that in .NET Framework.

Fox2Code commented 4 months ago

Windows.Foundation.UniversalApiContract.dll is clearly dotnet5+ according to nuget.

And you are telling me the Minecraft installer declare itself as dotnet4, while it uses that.

Either nuget website is drunk, and both this issue and #151 are dotnet4 features, or it expect dotnet4 to be dotnet5 in some way?

Maybe Wine-Mono wrongly detect MinecraftSetup.exe as dotnet4 while it's dotnet5? Maybe some hidden flag?

Fox2Code commented 4 months ago

I think talking about it in #197 is maybe better.