AvaloniaUI / AvaloniaVS

Visual Studio Extension for Avalonia
MIT License
421 stars 81 forks source link

Designer does not load for x86 projects #374

Open aholeton opened 1 year ago

aholeton commented 1 year ago

Describe the bug

When the application is built as an x86 application, the designer throws an error and the preview displays a "Process Exited" error message. Changing the application to a x64 application and rebuilding it, will cause the designer to correctly render the view.

To Reproduce

  1. Create a new Avalonia project using the wizard
  2. Add <PlatformTarget>x86</PlatformTarget> to the csproj file
  3. Build the application
  4. When opening any of the views, the designer fails to display a preview of the view

AvaloniaVS plugin version

11.1

Avalonia version

11.0

Visual Studio version

17.7

Relevant log output

16:10:01.612 [Information]  Stopping previewer process
16:10:01.612 [Information]  Stopping previewer process
16:10:02.895 [Information] 0 Starting previewer process for '"C:\code\AvaloniaApplication1\AvaloniaApplication1.Desktop\bin\Debug\net7.0\AvaloniaApplication1.Desktop.dll"'
16:10:02.905 [Information] 19412 Started previewer process for '"C:\code\AvaloniaApplication1\AvaloniaApplication1.Desktop\bin\Debug\net7.0\AvaloniaApplication1.Desktop.dll"'. Waiting for connection to be initialized.
16:10:03.055 [Information] 19412 Connection initialized
16:10:03.083 [Error] 19412 <= "Unhandled exception. System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation."
16:10:03.084 [Error] 19412 <= " ---> System.IO.FileNotFoundException: Could not load file or assembly 'AvaloniaApplication1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified."
16:10:03.085 [Error] 19412 <= "File name: 'AvaloniaApplication1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'"
16:10:03.086 [Error] 19412 <= "   at AvaloniaApplication1.Desktop.Program.BuildAvaloniaApp()"
16:10:03.086 [Error] 19412 <= "   at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)"
16:10:03.086 [Error] 19412 <= "   at System.Reflection.MethodInvoker.Invoke(Object obj, IntPtr* args, BindingFlags invokeAttr)"
16:10:03.093 [Error] 19412 <= "   --- End of inner exception stack trace ---"
16:10:03.094 [Error] 19412 <= "   at System.Reflection.MethodInvoker.Invoke(Object obj, IntPtr* args, BindingFlags invokeAttr)"
16:10:03.095 [Error] 19412 <= "   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)"
16:10:03.096 [Error] 19412 <= "   at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)"
16:10:03.097 [Error] 19412 <= "   at Avalonia.AppBuilder.Configure(Type entryPointType)"
16:10:03.097 [Error] 19412 <= "   at Avalonia.DesignerSupport.Remote.RemoteDesignerEntryPoint.Main(String[] cmdline)"
16:10:03.098 [Error] 19412 <= "   at Avalonia.Designer.HostApp.Program.Main(String[] args)"
16:10:03.638 [Information]  Process exited

Additional context

No response

Flithor commented 1 year ago

AnyCPU too. It happened suddenly, I was work on AnyCPU a day ago, and today suddenly the designer only tried to read the dll under x64.

Edit: Weird, it disappear..

Tesserex commented 10 months ago

Similar issue here, but for me it's a FileLoadException, as if it's loading two different platforms between the Desktop and main app, but everything is x86 only in my project. It worked for like 30 minutes on day one, and has never worked since.

08:40:57.280 [Information] 0 Starting previewer process for '"C:\junk\Code\MegaMan\Engine\Engine.Avalonia.Desktop\bin\x86\Debug\net6.0\Engine.Avalonia.Desktop.dll"'
08:40:57.280 [Debug] 0 > dotnet.exe "exec --runtimeconfig \"C:\junk\Code\MegaMan\Engine\Engine.Avalonia.Desktop\bin\x86\Debug\net6.0\Engine.Avalonia.Desktop.runtimeconfig.json\" --depsfile \"C:\junk\Code\MegaMan\Engine\Engine.Avalonia.Desktop\bin\x86\Debug\net6.0\Engine.Avalonia.Desktop.deps.json\" \"C:\Users\Tesserex\.nuget\packages\avalonia\11.0.5\buildTransitive\\..\tools\netcoreapp2.0\designer\Avalonia.Designer.HostApp.dll\" --transport tcp-bson://127.0.0.1:50688/ \"C:\junk\Code\MegaMan\Engine\Engine.Avalonia.Desktop\bin\x86\Debug\net6.0\Engine.Avalonia.Desktop.dll\""
08:40:57.289 [Information] 40452 Started previewer process for '"C:\junk\Code\MegaMan\Engine\Engine.Avalonia.Desktop\bin\x86\Debug\net6.0\Engine.Avalonia.Desktop.dll"'. Waiting for connection to be initialized.
08:40:57.420 [Verbose] 40452 Started PreviewerProcess.ConnectionInitializedAsync()
08:40:57.421 [Information] 40452 Connection initialized
08:40:57.422 [Debug] 40452 => Sending ClientSupportedPixelFormatsMessage { Formats: [Bgra8888, Rgba8888] }
08:40:57.423 [Debug] 40452 => Sending ClientRenderInfoMessage { DpiX: 96, DpiY: 96 }
08:40:57.424 [Verbose] 40452 Finished PreviewerProcess.ConnectionInitializedAsync()
08:40:57.425 [Verbose] 40452 Finished PreviewerProcess.StartAsync()
08:40:57.426 [Debug] 40452 => Sending UpdateXamlMessage { Xaml: "<UserControl xmlns=\"https://git…", AssemblyPath: "C:\junk\Code\MegaMan\Engine\Eng…", XamlFileProjectPath: null }
08:40:57.427 [Verbose]  Finished AvaloniaDesigner.StartProcessAsync()
08:40:57.449 [Error] 40452 <= "Unhandled exception. System.IO.FileLoadException: Could not load file or assembly 'Engine.Avalonia.Desktop, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'."
08:40:57.451 [Error] 40452 <= "   at System.Runtime.Loader.AssemblyLoadContext.LoadFromPath(IntPtr ptrNativeAssemblyLoadContext, String ilPath, String niPath, ObjectHandleOnStack retAssembly)"
08:40:57.452 [Error] 40452 <= "   at System.Runtime.Loader.AssemblyLoadContext.LoadFromAssemblyPath(String assemblyPath)"
08:40:57.453 [Error] 40452 <= "   at System.Reflection.Assembly.LoadFile(String path)"
08:40:57.454 [Error] 40452 <= "   at Avalonia.DesignerSupport.Remote.RemoteDesignerEntryPoint.Main(String[] cmdline)"
08:40:57.455 [Error] 40452 <= "   at Avalonia.Designer.HostApp.Program.Main(String[] args)"
08:40:59.684 [Information]  Process exited
kekekeks commented 9 months ago

Previewer is using system-installed dotnet executable from system PATH. Make sure that your app can be started via dotnet exec bin/Debug/net6.0/YourApp.dll

Takoooooo commented 9 months ago

Not planned currently. It will take a long time to add support and we don't see many people asking for it.

maxkatz6 commented 9 months ago

Side note: I don't think there is any reason to use PlatformTarget or Platforms properties when building .NET Core apps. It was useful in .NET Framework but not anymore. Please use runtime identifiers instead https://github.com/dotnet/sdk/issues/1553