GithubHelp home page GithubHelp logo

Comments (17)

LanceMcCarthy avatar LanceMcCarthy commented on July 21, 2024 1

I'm going to take another stab at this in the morning, have to sign off. I'll have a 19041 VM spun up and will be able to hopefully be a little more helpful.

[update] just got your latest message halfway through typing, lol.

The two crashes probably do have two separate causes, but these kinds of things happen at the same time tend to make me suspect larger issue.

from brainf_cksharp.

Sergio0694 avatar Sergio0694 commented on July 21, 2024

Hey Lance, just so that I understand, how did you manage to get past the initial startup crash in Release mode? I mean, if you got to repro the crash with the context menu in Release mode I take it you found a way to avoid that initial crash somehow? 🤔

from brainf_cksharp.

LanceMcCarthy avatar LanceMcCarthy commented on July 21, 2024

I have not been able to see the initial crash, but I did fix this crash.

The controls library was not merging the resources, update Themes/Generic.xaml to:

<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
    <ResourceDictionary.MergedDictionaries>
        <XamlControlsResources xmlns="using:Microsoft.UI.Xaml.Controls" />
        <ResourceDictionary Source="Brainf_ckEditBox/Brainf_ckEditBox.xaml"/>
    </ResourceDictionary.MergedDictionaries>
</ResourceDictionary>

from brainf_cksharp.

LanceMcCarthy avatar LanceMcCarthy commented on July 21, 2024

Also, app.xaml in the main project should be merging the Themes dictionary:

<Application
    x:Class="Brainf_ckSharp.Uwp.App"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    RequestedTheme="Dark">
    <Application.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <XamlControlsResources xmlns="using:Microsoft.UI.Xaml.Controls"/>
                <ResourceDictionary Source="Resources/Dictionaries/Brushes.xaml"/>
                <ResourceDictionary Source="Resources/Dictionaries/IconPaths.xaml"/>
                <ResourceDictionary Source="Resources/Dictionaries/MDL2Icons.xaml"/>
                <ResourceDictionary Source="Styles/ButtonsStyles.xaml"/>
                <ResourceDictionary Source="Styles/ClassicStyles.xaml"/>
                <ResourceDictionary Source="Styles/MiscStyles.xaml"/>
                <ResourceDictionary Source="Styles/TextStyles.xaml"/>
                <ResourceDictionary Source="Brainf_ckSharp.Uwp.Controls.Ide/Themes/Generic.xaml"/>
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </Application.Resources>
</Application>

from brainf_cksharp.

LanceMcCarthy avatar LanceMcCarthy commented on July 21, 2024

Nevermind about that last one, when I merge themes in App.xaml, it now crashes at launch

from brainf_cksharp.

Sergio0694 avatar Sergio0694 commented on July 21, 2024

Oh, so I was merging the resource dictionaries wrong in the class library! 🤦‍♂️

If the startup crash you're getting is this:

Exception "The text associated with this error code could not be found. Failed to assign to property 'Windows.UI.Xaml.ResourceDictionary.Source' because the type 'Windows.Foundation.String' cannot be assigned to the type 'Windows.Foundation.Uri'. [Line: 21 Position: 37]"} System.Exception {Windows.UI.Xaml.Markup.XamlParseException}

Apparently this is fixed by leaving ms-app:/// as the URI scheme for the resources in the class library. Looks like for some reason it can't parse the URI if you don't use this format 🤔

Which is weird, because apparently the app can do that just fine instead 🤷‍♂️

from brainf_cksharp.

Sergio0694 avatar Sergio0694 commented on July 21, 2024

I have two side questions:

  1. Why was the crash only exhibiting with .NET Native, and specifically in Release mode?
  2. Since I now have those WinUI XamlControlsResources dictionaries in both the app and the class library, should I be worried that those styles would be instantiated twice? Or would the XAML parser be able to recognize them and only create those styles once to save resources? In case that matters at all, that is, not sure how merged resources work exactly in this scenario 😅

from brainf_cksharp.

LanceMcCarthy avatar LanceMcCarthy commented on July 21, 2024

Ah, let me try that again for the Editbox styles (thanks Resharper).

About the resources, you can't always rely on the downstream library consumer. You would think that having a style in App.xaml would make it available for everything, no matter where it comes from, but the external project is not just some XAML files that get compiled into the main project.

Rather, the library gets compiled first (only aware of Windows.UI.Xaml), while the main project is compiling for Microsoft.UI.Xaml.

I'm just making educated guesses at this point, based on the nature of the exceptions and the fact that it's .NET Native compilation stripping out the unreferenced parts.

from brainf_cksharp.

LanceMcCarthy avatar LanceMcCarthy commented on July 21, 2024

Launch is fixed, but the context menu exception is still happening. Not sure why it stopped for a while, needing to compile with WinUI types is a red herring.

from brainf_cksharp.

Sergio0694 avatar Sergio0694 commented on July 21, 2024

Just to double check, have you see my message in the other issue here?
I mean, with "launch is fixed" you mean before or after that?

from brainf_cksharp.

LanceMcCarthy avatar LanceMcCarthy commented on July 21, 2024

Launch has always worked for me with Release builds. Installed msix after publishing as side-loadable package)

The only reason it stopped working was because of the Uri.

Here's the packaging setting:
image

from brainf_cksharp.

Sergio0694 avatar Sergio0694 commented on July 21, 2024

I see. This is weird. It makes me think there's this crash in the context menu on one end which we can investigate, and the one I'm seeing at startup which might be an SDK bug instead?

I mean, you and I are running the same exact code, and for me the app is just exploding at startup, the only difference I can see is that I'm on 19041. Which would also explain why my other app Legere is exhibiting the same exact behavior - it explodes at startup in Release as well 🤦‍♂️

from brainf_cksharp.

Sergio0694 avatar Sergio0694 commented on July 21, 2024

@LanceMcCarthy By the way, we have a ton of WinUI devs in our UWP Discord server, if you wanted to join we could talk there as well! We'd be happy to have you 😊

Right now there's Steven Brix (from the WinUI team) that's asking about this issue and I'm just relaying info from here, you could talk to him directly in there if you wanted.

from brainf_cksharp.

Sergio0694 avatar Sergio0694 commented on July 21, 2024

Sounds great, that's awesome! No worries, I'll be looking forward for an update once you have the 19041 VM setup then, that'll definitely be useful! Thanks again 😊

And yeah I definitely agree with you that all these weird issues at once are very suspicious.

from brainf_cksharp.

LanceMcCarthy avatar LanceMcCarthy commented on July 21, 2024

I'm so tired that I completely missing ITemsPresenter and ContentPresenter, lol.

in IdeView.xaml change:

    <!--IDE-->
    <ide:Brainf_ckIde x:Name="CodeEditor">
        <ide:Brainf_ckIde.ContextMenuSecondaryContent>
            <ItemsControl
                ItemsSource="{x:Bind constants:CodeSnippets.All}"
                ItemTemplate="{x:Bind CodeSnippetTemplate}">
                <ItemsControl.ItemContainerStyle>
                    <Style TargetType="ItemsPresenter">
                        <Setter Property="HorizontalAlignment" Value="Stretch"/>
                    </Style>
                </ItemsControl.ItemContainerStyle>
            </ItemsControl>
        </ide:Brainf_ckIde.ContextMenuSecondaryContent>
    </ide:Brainf_ckIde>
</UserControl>

To

    <!--IDE-->
    <ide:Brainf_ckIde x:Name="CodeEditor">
        <ide:Brainf_ckIde.ContextMenuSecondaryContent>
            <ItemsControl
                ItemsSource="{x:Bind constants:CodeSnippets.All}"
                ItemTemplate="{x:Bind CodeSnippetTemplate}">
                <ItemsControl.ItemContainerStyle>
                    <Style TargetType="ContentPresenter">
                        <Setter Property="HorizontalAlignment" Value="Stretch"/>
                    </Style>
                </ItemsControl.ItemContainerStyle>
            </ItemsControl>
        </ide:Brainf_ckIde.ContextMenuSecondaryContent>
    </ide:Brainf_ckIde>
</UserControl>

from brainf_cksharp.

Sergio0694 avatar Sergio0694 commented on July 21, 2024

I feel so stupid, I mixed those two up 🤣

Thank you so much for spotting this! Commented in the other issue 👍

from brainf_cksharp.

Sergio0694 avatar Sergio0694 commented on July 21, 2024

Closing this as I think the issue is fixed now (can right click and it works just fine). Thank you again for the help! 😄

from brainf_cksharp.

Related Issues (4)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.