AvaloniaCommunity/Material.Avalonia

ColorPicker in Release mode

MetacodeX7 opened this issue · 8 comments

Hi,

I'm using Avalonia 11 preview 8 and Material 3.0.0-avalonia11-preview4.167-nightly. I've been getting an exception at startup, but only in Release mode:
Unhandled exception. System.IO.FileNotFoundException: Could not load file or assembly 'Avalonia.Controls.ColorPicker'

The issue does not happen if Material.Avalonia is removed from the project, or when using Avalonia 11 preview 6 with Material 11-preview4.

Ahh I see that there is a separate prerelease package for ColorPicker. All that's missing is the dependency I guess.

Hello, @Nimred

We don't use or stylize ColorPicker in Material.Avalonia at all.
But, seems like Avalonia.Diagnostics (dev tools) rely on it. So, it will be implicitly referenced by Avalonia.Diagnostics. But i guess you have something like this is your csproj:

<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics"

So, in release mode ColorPicker package will not be included in your project, since it will no be required by Avalonia.Diagnostics.

Diagnostics wasn't present in the project I confirmed the dependency with, but I did find the line you mentioned.

After removing it just to be sure, the ColorPicker exception still occurs. On the other hand, as soon as the Material.Avalonia package and <themes:MaterialTheme ... /> line are removed, the ColorPicker exception does not occur anymore. Doesn't this suggest that the dependency comes from Material.Avalonia?

Hmm, this is kinda strange. We don't use it. Can you provide a project example?

Icons11Test.zip

Here you go. Steps:

  1. Build Desktop project in Release, confirm it runs correctly without exception
  2. Add Material 3.0.0-avalonia11-preview4.167-nightly and uncomment the theme lines in App.axml
  3. Confirm exception when running

Hmm, seemls like it works perfectly for me. I've added a Material 3.0.0-avalonia11-preview4.167-nightly, fixed Avalonia.Diagnostics version="11.0.0-preview8" and uncomment styles in App.axaml. Here is the project files: Icons11Test.zip

What happens when you remove Avalonia.Diagnostics?

When you added Avalonia.Diagnostics, it also added the ColorPicker package that it depends on. If Material.Avalonia has a hidden dependency on ColorPicker, the exception will only show up when there's no Avalonia.Diagnostic package, or when Diagnostics is disabled in Release.

Perhaps this doesn't matter much anyway, as everyone is likely to use the Diagnostics package.

Yep, seems like it has been fixed via this change. To try it you can use 3.0.0-avalonia11-preview4.172-nightly version.