oxyplot / oxyplot-avalonia

A cross-platform plotting library for .NET. This package targets Avalonia apps.
https://oxyplot.github.io/
MIT License
274 stars 47 forks source link

Running into an Avalonia.Markup.Xaml.XamlLoadException #58

Closed jorgedevs closed 1 year ago

jorgedevs commented 1 year ago

I updated my Avalonia project to 11.0.4, and trying to add oxyplot to my app. I add the NuGet package, add the Style in App.axaml,

<Application 
    xmlns="https://github.com/avaloniaui"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:AvaloniaGreenhouse"
    x:Class="AvaloniaGreenhouse.App">

    <Application.Styles>
        <SimpleTheme/>
        <StyleInclude Source="avares://OxyPlot.Avalonia/Themes/Default.axaml"/>
    </Application.Styles>
</Application>

Running the app to make sure it builds and runs, I get the following exception:

Avalonia.Markup.Xaml.XamlLoadException HResult=0x80131500 Message=No precompiled XAML found for avares://OxyPlot.Avalonia/Themes/Default.axaml (baseUri: avares://AvaloniaGreenhouse/App.axaml), make sure to specify x:Class and include your XAML file as AvaloniaResource Source=Avalonia.Markup.Xaml StackTrace: at Avalonia.Markup.Xaml.AvaloniaXamlLoader.Load(IServiceProvider sp, Uri uri, Uri baseUri) at Avalonia.Markup.Xaml.Styling.StyleInclude.get_Loaded() at Avalonia.Markup.Xaml.Styling.StyleInclude.Avalonia.Controls.IResourceProvider.AddOwner(IResourceHost owner) at Avalonia.Styling.Styles.InternalAdd(IList items, IResourceHost owner) at Avalonia.Styling.Styles.OnCollectionChanged(Object sender, NotifyCollectionChangedEventArgs e) at Avalonia.Collections.AvaloniaList1.NotifyAdd(T item, Int32 index) at Avalonia.Collections.AvaloniaList1.Add(T item) at Avalonia.Styling.Styles.Add(IStyle item) at AvaloniaGreenhouse.App.!XamlIlPopulate(IServiceProvider , App ) in C:\Projects\Meadow.Desktop.Samples\Source\Windows\AvaloniaGreenhouse\App.axaml:line 9 at AvaloniaGreenhouse.App.!XamlIlPopulateTrampoline(App ) at AvaloniaGreenhouse.App.Initialize() in C:\Projects\Meadow.Desktop.Samples\Source\Windows\AvaloniaGreenhouse\App.axaml.cs:line 14 at Avalonia.AppBuilder.SetupUnsafe() at Avalonia.AppBuilder.Setup() at Avalonia.AppBuilder.SetupWithLifetime(IApplicationLifetime lifetime) at Avalonia.ClassicDesktopStyleApplicationLifetimeExtensions.StartWithClassicDesktopLifetime(AppBuilder builder, String[] args, ShutdownMode shutdownMode) at AvaloniaGreenhouse.App.Main(String[] args) in C:\Projects\Meadow.Desktop.Samples\Source\Windows\AvaloniaGreenhouse\App.axaml.cs:line 37

I've compared what I have with your example projects and I have no idea how to solve that exception.

kekekeks commented 1 year ago

It seems that the version on nuget.org is still targeting 0.10.x. Consider using https://github.com/oxyplot/oxyplot-avalonia/ as a submodule for now

jorgedevs commented 1 year ago

hm ok, I can downgrade and try the nuget version, I'll report back (and close issue if I get it working). Thanks for the quick reply,

VisualMelon commented 1 year ago

There is a 2.1.0-Avalonia11 version on nuget... I'm not sure why it isn't listed on nuget this minute...

VisualMelon commented 1 year ago

I will probably release a version 2.1.2 which is Av11 only, because I've not had any feedback suggesting I should do otherwise, but that won't be for a week or so.

jorgedevs commented 1 year ago

Release as a beta, maybe? I'd be happy to give it a try. :)

VisualMelon commented 1 year ago

Should just need <PackageReference Include="OxyPlot.Avalonia" Version="2.1.0-Avalonia11" /> in your csproj

Sorry, you meant for 2.1.2: yes, nothing stopping me, but I don't like to rush nuget deployments because I have a history of getting them wrong.

jorgedevs commented 1 year ago

Understood, i cant find this 2.1.0-Avalonia11 version.

image

Im gonna close this issue. I'll use the Avalonia version that's compatible with the oxyplot Nuget version, and figure out the API changes (if any).

Thank you all for the assist.

VisualMelon commented 1 year ago

I am very confused. Anyhow, I've pushed 2.1.0-Avalonia11 to nuget just now, so hopefully it will actually work now.

jorgedevs commented 1 year ago

Sorry, thought you meant that the package was already out. Anyways, I have made progress with latest stable version, and I can see the plotting canvas on Windows (left), but running it on my Raspberry Pi (right), i dont see it. Do you guys support Linux, by any chance?

image

VisualMelon commented 1 year ago

Sorry, thought you meant that the package was already out.

I did: it's I that was mistaken.... and now very very confused because it means I have no idea how my Linux box was using it.

Do you guys support Linux, by any chance?

I use OxyPlot.Avalonia 11 on Linux all the time (somehow); can't recall having tested 0.10 but I have no reason to believe it wouldn't work

jorgedevs commented 1 year ago

Ok, then good timing releasing the avalonia 11 preview (Nuget). I'll update my Avalonia back to 11 and try again, hopefully it works.

I'll keep you posted.

VisualMelon commented 1 year ago

Sorry for all the confusion (my fault entirely)

jorgedevs commented 1 year ago

oh all good, I appreciate your quick responses, I have a deadline for this to work so you're support is welcome so I can keep going.

jorgedevs commented 1 year ago

Progress!

PXL_20230911_191959305

I was missing a few more setup things, fortunately was able to figure it out comparing with the samples (which now match the versions I have).

Thanks again. I might open more Issues if I run into any more hiccups. :)

VisualMelon commented 1 year ago

If you have vague/throw-away questions, feel free to ask in the gitter: https://app.gitter.im/#/room/#oxyplot_oxyplot:gitter.im