SimpleToolkit icon indicating copy to clipboard operation
SimpleToolkit copied to clipboard

Can not use Simple Shell "Unable to cast object of type 'Microsoft.Maui.Controls.Handlers.ShellItemHandler' to type 'SimpleToolkit.SimpleShell.Handlers.SimpleShellItemHandler"

Open BeepBeepBopBop opened this issue 1 year ago • 1 comments

Hi I wanted to try the toolkit but unfortunately I am getting an error whenever I launch my app on Windows:

{"Unable to cast object of type 'Microsoft.Maui.Controls.Handlers.ShellItemHandler' to type 'SimpleToolkit.SimpleShell.Handlers.SimpleShellItemHandler'."}

What I did was to simply follow the Sample and I tried to track down my issue for the last couple hours without success.

I stripped my shell to the most basic possible and it looks like this:

<?xml version="1.0" encoding="UTF-8" ?>
<simpleShell:SimpleShell
    x:Class="BoxingTimer.AppShell"
    xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
    xmlns:local="clr-namespace:BoxingTimer"
    xmlns:simpleShell="clr-namespace:SimpleToolkit.SimpleShell;assembly=SimpleToolkit.SimpleShell"
    x:Name="thisShell">


    <ShellContent
        Title="Home"
        ContentTemplate="{DataTemplate local:HomePage}"
        Route="MainPage" />

</simpleShell:SimpleShell>

I did include .UseSimpleShell() .UseSimpleToolkit()

Maybe you can help me troubleshooting this, I have tried with a new .NET8 application and it worked fine though

Full stack trace:

at SimpleToolkit.SimpleShell.Handlers.SimpleShellHandler.CreateShellItemHandler() at SimpleToolkit.SimpleShell.Handlers.SimpleShellHandler.SwitchShellItem(ShellItem newItem, Boolean animate) at SimpleToolkit.SimpleShell.Handlers.SimpleShellHandler.MapCurrentItem(SimpleShellHandler handler, ISimpleShell shell) at Microsoft.Maui.PropertyMapper2.<>c__DisplayClass5_0.<Add>b__0(IElementHandler h, IElement v) at Microsoft.Maui.PropertyMapper.UpdatePropertyCore(String key, IElementHandler viewHandler, IElement virtualView) at Microsoft.Maui.PropertyMapper.UpdateProperty(IElementHandler viewHandler, IElement virtualView, String property) at Microsoft.Maui.Handlers.ElementHandler.UpdateValue(String property) at SimpleToolkit.SimpleShell.Handlers.SimpleShellHandler.MapContent(SimpleShellHandler handler, ISimpleShell shell) at Microsoft.Maui.PropertyMapper2.<>c__DisplayClass5_0.<Add>b__0(IElementHandler h, IElement v) at Microsoft.Maui.PropertyMapper.UpdatePropertyCore(String key, IElementHandler viewHandler, IElement virtualView) at Microsoft.Maui.PropertyMapper.UpdateProperties(IElementHandler viewHandler, IElement virtualView) at Microsoft.Maui.Handlers.ElementHandler.SetVirtualView(IElement view) at Microsoft.Maui.Handlers.ViewHandler2.SetVirtualView(IView view) at Microsoft.Maui.Handlers.ViewHandler2.SetVirtualView(IElement view) at Microsoft.Maui.Controls.Element.SetHandler(IElementHandler newHandler) at Microsoft.Maui.Controls.Element.set_Handler(IElementHandler value) at Microsoft.Maui.Controls.VisualElement.Microsoft.Maui.IElement.set_Handler(IElementHandler value) at Microsoft.Maui.Platform.ElementExtensions.ToHandler(IElement view, IMauiContext context) at Microsoft.Maui.Platform.ElementExtensions.ToPlatform(IElement view, IMauiContext context) at Microsoft.Maui.Handlers.WindowHandler.MapContent(IWindowHandler handler, IWindow window) at Microsoft.Maui.PropertyMapper`2.<>c__DisplayClass5_0.<Add>b__0(IElementHandler h, IElement v) at Microsoft.Maui.PropertyMapper.UpdatePropertyCore(String key, IElementHandler viewHandler, IElement virtualView) at Microsoft.Maui.PropertyMapper.UpdateProperties(IElementHandler viewHandler, IElement virtualView) at Microsoft.Maui.Handlers.ElementHandler.SetVirtualView(IElement view) at Microsoft.Maui.Controls.Element.SetHandler(IElementHandler newHandler) at Microsoft.Maui.Controls.Element.set_Handler(IElementHandler value) at Microsoft.Maui.Platform.ElementExtensions.SetHandler(IWinRTObject nativeElement, IElement element, IMauiContext context) at Microsoft.Maui.Platform.ElementExtensions.SetWindowHandler(Window platformWindow, IWindow window, IMauiContext context) at Microsoft.Maui.Platform.ApplicationExtensions.CreatePlatformWindow(Application platformApplication, IApplication application, OpenWindowRequest args) at Microsoft.Maui.Platform.ApplicationExtensions.CreatePlatformWindow(Application platformApplication, IApplication application, LaunchActivatedEventArgs args) at Microsoft.Maui.MauiWinUIApplication.OnLaunched(LaunchActivatedEventArgs args) at Microsoft.UI.Xaml.Application.Microsoft.UI.Xaml.IApplicationOverrides.OnLaunched(LaunchActivatedEventArgs args) at ABI.Microsoft.UI.Xaml.IApplicationOverrides.Do_Abi_OnLaunched_0(IntPtr thisPtr, IntPtr args)

BeepBeepBopBop avatar Nov 27 '23 21:11 BeepBeepBopBop

Hi @BeepBeepBopBop,

do you use any other library or your own ShellItem handler implementation in your project? I have no idea what could have caused the exception.

RadekVyM avatar Dec 16 '23 12:12 RadekVyM