Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
BeepBeepBopBop opened this issue Nov 27, 2023 · 1 comment

Comments

@BeepBeepBopBop
Copy link

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.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.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 BeepBeepBopBop changed the title Can not use Simple Shell Can not use Simple Shell "Unable to cast object of type 'Microsoft.Maui.Controls.Handlers.ShellItemHandler' to type 'SimpleToolkit.SimpleShell.Handlers.SimpleShellItemHandler" Nov 27, 2023
@RadekVyM
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants