dotMorten / WinUIEx

WinUI Extensions
https://dotmorten.github.io/WinUIEx
MIT License
573 stars 36 forks source link

"Specified cast is not valid" on launch after upgrading from 2.1.0 to 2.2.0 #128

Closed zipgenius closed 9 months ago

zipgenius commented 1 year ago

I created a new Winui3 Packaged app and added WinUIEx 2.2.0. I also upgraded the following:

I modified my MainWindow.xaml.cs as follows:

using WinUIEx;
public sealed partial class MainWindow : WindowEx

and MainWindow.xaml as follows:

<?xml version="1.0" encoding="utf-8"?>
<winuiex:WindowEx
    xmlns:winuiex="using:WinUIEx"
    x:Class="zgx_test_2.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:zgx_test_2"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d">

    <StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center">
        <Button x:Name="myButton" Click="myButton_Click">Click Me</Button>
    </StackPanel>
</winuiex:WindowEx>

When I try to run the app, I get this error:

image

Am I missing anything?

dotMorten commented 10 months ago

I can't really tell from what you're showing. Could you attach a small simple project that reproduces the issue?

dotMorten commented 9 months ago

Went through the steps a few times without being able to reproduce. Also looked through changes between 2.1 and 2.2 and don't see anything obvious that points to potential new cast exceptions. Lastly the screenshot above seem to indicate the exception is coming from native code in WinRT.Runtime.dll.

At this point I'm not able to move forward on the issue. I'm going to close it, but if you have a simple project that reproduces the issue, feel free to add it here and reopen.

interrobot commented 5 months ago

The same issue zipgenius had, happened to me. I suspect it is the SDK retargeting. In my case, WinAppSDK 1.3.x was never stable either, but 1.2.x and 1.4.x both are.