-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
How to run an Avalonia project with mono #2504
Comments
For some reason MSBuild is failing to copy the native library to bin/Debug. You can do that manually from |
Also make sure to |
Also, if you are planning to use Mono as the runtime, it's probably better to target |
For old Mono versions it might be also required to add the directory with |
Thanks for all tips... Our strategic changes here, and maybe we won´t use more Mono. Anyway, I do these tests that you mentioned Thanks |
Hello,
|
Probably SkiaSharp version mismatch. sk_refcnt_safe_unref only exists in SkiaSharp 1.68.1 which is not binary compatible with the previous version in terms of the native binary. |
Thank you. That was the problem. I had also Mapsui with different skia requirement. |
So basically Avalonia is broken/unsupported for Mono from the looks of it.There are no docs concerning how to use Avalonia on Mono either so I'm assuming this is a .Net Core implementation only. |
We are running our tests with legacy .NET TFM. Mono runtime is supported, we are also using it for iOS and Android. Mono build ecosystem, however, is not supported. You need to manually copy required native bits and ensure that Mono P/Invoke loader finds them or supply LD_LIBRARY_PATH. Basically we require Mono users to be proficient with Mono and Unix. |
There seems to be zero documentation to what you describe (Mono build not being supported). Also, what are the native bits required? I assume it's libSkiaSharp.so and libHarfBuzzSharp.so which I did manually include. Except Avalonia segfaults on Linux with these libraries. So I'm guessing this wasn't made with Linux compatibility in mind? Either that or there was a breaking change for Linux. The .Net Core version works fine on Linux but the mono version segfaults. |
Mkay, I've just checked and it turns out that Avalonia works with Mono mostly out of the box except for a bug in SkiaSharp and HarfbuzzSharp that overwrite native binaries with ones built for musl. <Target Name="SkiaSharpRemoveMusl" BeforeTargets="BeforeBuild">
<ItemGroup>
<Content Remove="@(Content)" Condition="$([System.Text.RegularExpressions.Regex]::IsMatch('%(FullPath)', 'packages.*linux-musl.*so')) "/>
</ItemGroup>
</Target>
to csproj file. You can find a working example here: https://github.com/kekekeks/AvaloniaMonoDemo |
Ok that example project seems to work. But projects I have made using msbuild don't. Might I ask you how did you generate the project files? As I cannot build the project for mono since there seem to be no build systems available. The projects I built were built with msbuild for .Net 5 and then downgraded to .Net 4.72, though I believe this is why it is not working on Mono, I don't know. Is there any way of building everything in Linux? I can't use Visual Studio to build the project. |
|
For .NET 5 SDK this is not needed, it is already included :) Some things can even be run on Linux 😏 |
Thanks for reporting this and sorry for the long delay. I was doing crazy things with MAUI. I see what I did was basically dumb. What would work in a typical case? Would you want to compile for both glibc and musl and have some runtime check (that I am not sure of the best way to do) or have a project property that you set, say |
Hi people.
Sorry if duplicated, but I can´t find any.
Explain my context:
I did a sample avalonia project using Visual Studio (windows 10), then I published the project (Rigth click on Project in solution explorer -> Publish option). So, I transfered the publish folder content to virtual machine with Ubuntu Linux (v18.04), and finally, run the app using the follow command:
dotnet AppName.dll
It works as expected.
But, I need to run this same app with Mono compiler. So I installed the mono (v5.20.1.19) in this VM and run the follow command:
mono AppName.dll
Here is the problem:
Unhandled Exception: System.DllNotFoundException: libSkiaSharp at (wrapper managed-to-native) SkiaSharp.SkiaApi.gr_glinterface_assemble_gl_interface(intptr,intptr) at SkiaSharp.GRGlInterface.AssembleGlInterface (System.Object context, SkiaSharp.GRGlGetProcDelegate get) [0x00010] in <f0c24c4dec0742d096b8ec67614c0af5>:0 at SkiaSharp.GRGlInterface.AssembleGlInterface (SkiaSharp.GRGlGetProcDelegate get) [0x00001] in <f0c24c4dec0742d096b8ec67614c0af5>:0 at Avalonia.Skia.PlatformRenderInterface..ctor () [0x00056] in <495233f1b3044dd08c7fe9b76254ab31>:0 at Avalonia.Skia.SkiaPlatform.Initialize () [0x00000] in <495233f1b3044dd08c7fe9b76254ab31>:0 at Avalonia.SkiaApplicationExtensions+<>c__0
1[T].b__0_0 () [0x00000] in <495233f1b3044dd08c7fe9b76254ab31>:0at Avalonia.Controls.AppBuilderBase
1[TAppBuilder].Setup () [0x00099] in <760632d2d12b408380559a5a34ba1e30>:0 at Avalonia.Controls.AppBuilderBase
1[TAppBuilder].Start (Avalonia.Controls.AppBuilderBase1+AppMainDelegate[TAppBuilder] main, System.String[] args) [0x00000] in <760632d2d12b408380559a5a34ba1e30>:0 at TelaToten.Program.Main (System.String[] args) [0x00005] in <dac6b87b16f445889ec2af036aef11db>:0 [ERROR] FATAL UNHANDLED EXCEPTION: System.DllNotFoundException: libSkiaSharp at (wrapper managed-to-native) SkiaSharp.SkiaApi.gr_glinterface_assemble_gl_interface(intptr,intptr) at SkiaSharp.GRGlInterface.AssembleGlInterface (System.Object context, SkiaSharp.GRGlGetProcDelegate get) [0x00010] in <f0c24c4dec0742d096b8ec67614c0af5>:0 at SkiaSharp.GRGlInterface.AssembleGlInterface (SkiaSharp.GRGlGetProcDelegate get) [0x00001] in <f0c24c4dec0742d096b8ec67614c0af5>:0 at Avalonia.Skia.PlatformRenderInterface..ctor () [0x00056] in <495233f1b3044dd08c7fe9b76254ab31>:0 at Avalonia.Skia.SkiaPlatform.Initialize () [0x00000] in <495233f1b3044dd08c7fe9b76254ab31>:0 at Avalonia.SkiaApplicationExtensions+<>c__0
1[T].b__0_0 () [0x00000] in <495233f1b3044dd08c7fe9b76254ab31>:0at Avalonia.Controls.AppBuilderBase
1[TAppBuilder].Setup () [0x00099] in <760632d2d12b408380559a5a34ba1e30>:0 at Avalonia.Controls.AppBuilderBase
1[TAppBuilder].Start (Avalonia.Controls.AppBuilderBase1+AppMainDelegate[TAppBuilder] main, System.String[] args) [0x00000] in <760632d2d12b408380559a5a34ba1e30>:0 at TelaToten.Program.Main (System.String[] args) [0x00005] in <dac6b87b16f445889ec2af036aef11db>:0
The text was updated successfully, but these errors were encountered: