AvaloniaUI / Avalonia

Develop Desktop, Embedded, Mobile and WebAssembly apps with C# and XAML. The most popular .NET UI client technology
https://avaloniaui.net
MIT License
25.8k stars 2.23k forks source link

Missing package "System.Net.Ping" #3587

Closed JesterX666 closed 1 year ago

JesterX666 commented 4 years ago

Our application uses Avalonia but it seems that it's missing some packages on some installations.

Most of our installations work fine but some have that exception:

Description: The process was terminated due to an unhandled exception. Exception Info: System.IO.FileNotFoundException: Could not load file or assembly 'System.Net.Ping, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified. File name: 'System.Net.Ping, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' at UnitystationLauncher.Models.ServerWrapper..ctor(Server server, AuthManager authManager, InstallationManager installManager) at UnitystationLauncher.Models.ServerManager.RefreshServerList() at System.Threading.Tasks.Task.<>c.b139_0(Object state) at Avalonia.Threading.AvaloniaSynchronizationContext.<>cDisplayClass5_0.b__0() at Avalonia.Threading.JobRunner.Job.Avalonia.Threading.JobRunner.IJob.Run() at Avalonia.Threading.JobRunner.RunJobs(Nullable`1 priority) at Avalonia.Win32.Win32Platform.WndProc(IntPtr hWnd, UInt32 msg, IntPtr wParam, IntPtr lParam) at Avalonia.Win32.Interop.UnmanagedMethods.DispatchMessage(MSG& lpmsg) at Avalonia.Win32.Win32Platform.RunLoop(CancellationToken cancellationToken) at Avalonia.Threading.Dispatcher.MainLoop(CancellationToken cancellationToken) at Avalonia.Controls.ApplicationLifetimes.ClassicDesktopStyleApplicationLifetime.Start(String[] args) at Avalonia.ClassicDesktopStyleApplicationLifetimeExtensions.StartWithClassicDesktopLifetime[T](T builder, String[] args, ShutdownMode shutdownMode) at UnitystationLauncher.Program.Main(String[] args)

MonkAlex commented 4 years ago

UnitystationLauncher.Models.ServerManager.RefreshServerList

So, why u think its Avalonia bug?

DooblyNoobly commented 4 years ago

@MonkAlex

Because the app fails to start at all randomly. Like it will work fine for a week then one day it will just refuse to launch. Happens on win and osx. Its like the bundled runtime just decides it will give up for some weird reason. This is the only log we have been able to get from the app.

DooblyNoobly commented 4 years ago

@MonkAlex btw this is the problem: Exception Info: System.IO.FileNotFoundException: Could not load file or assembly 'System.Net.Ping,

DooblyNoobly commented 4 years ago

this is on avalonia 0.9.2

Gillibald commented 4 years ago

This has nothing to do with Avalonia. This is a problem in your code.

DooblyNoobly commented 4 years ago

btw here is the output on mac:

machine:~ user$ /Applications/StationHub ; exit;
Error:
  An assembly specified in the application dependencies manifest (StationHub.deps.json) was not found:
    package: 'Avalonia.Direct2D1', version: '0.9.2'
    path: 'lib/netstandard2.0/Avalonia.Direct2D1.dll'
logout
Gillibald commented 4 years ago

Avalonia.Direct2D1 is Windows only. Pls show us your AppBuilder

DooblyNoobly commented 4 years ago

image

Gillibald commented 4 years ago

How do you publish the app?

DooblyNoobly commented 4 years ago

using dotnet publish. here is the command I use: dotnet publish /p:Configuration=ReleaseWIN64 /p:Platform="x64" -r win10-x64 /p:PublishSingleFile=true

Gillibald commented 4 years ago

And for Mac? This is targeting Windows.

DooblyNoobly commented 4 years ago

Mac: dotnet publish /p:Configuration=ReleasePOSIX64 /p:Platform="x64" -r osx-x64 /p:PublishSingleFile=true

Gillibald commented 4 years ago

Might be good to know what version of the runtime is installed on the system that show this error.

Gillibald commented 4 years ago

https://apisof.net/catalog/System.Net.NetworkInformation

kekekeks commented 4 years ago

PublishSingleFile

Don't use it. It's broken by design. It can and will cause issues on various machines.

DooblyNoobly commented 4 years ago

@kekekeks yikes I had suspicions

@Gillibald I know it has happened on this windows machine I am on and runtime version is: 4.0.30319.42000

kekekeks commented 4 years ago

machine:~ user$ /Applications/StationHub ; exit;
Error:
  An assembly specified in the application dependencies manifest (StationHub.deps.json) was not found:
    package: 'Avalonia.Direct2D1', version: '0.9.2'
    path: 'lib/netstandard2.0/Avalonia.Direct2D1.dll'
logout

This message suggests that you've tried to remove a dll referenced from your deps.json. That won't work with .NET Core.

If you want to trim the installation size, remove the reference to Avalonia.Desktop and reference Avalonia.Skia + Avalonia.Win32/Avalonia.X11/Avalonia.Native based on the target platform and call UseSkia, UseWin32/UseX11/UseAvaloniaNative directly.

DooblyNoobly commented 4 years ago

if there was any stripping then it wasn't on purpose

DooblyNoobly commented 4 years ago

I'm going to test a build with /p:PublishSingleFile=false for a week or so. Already it has solved another mystery bug I was experiencing on win10