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

TabbedPage inside Grid works in debug mode, but throws exception in release mode (Copy of #16326) #22457

Closed
svn2208 opened this issue May 16, 2024 · 2 comments
Labels
area-layout StackLayout, GridLayout, ContentView, AbsoluteLayout, FlexLayout, ContentPresenter layout-grid platform/macOS 🍏 macOS / Mac Catalyst t/bug Something isn't working

Comments

@svn2208
Copy link

svn2208 commented May 16, 2024

Description

For my application I have a Grid with a ContentView Left and a Tabbed Page right side.

VS: In DebugMode I see the Exception, but I can run the application. In ReleaseView it won't start.
MS Code: It does not start in ether of the modes.

Exception:
2024-05-16 15:32:02.732 MyMauiApp[21498:10520592]
Unhandled Exception:
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
---> System.InvalidOperationException: Parent of a Page must also be a Page

Steps to Reproduce

  1. Create a App Example with dotnet new maui -n "MyMauiApp"
  2. Modify Mainpage.xml to
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="MyMauiApp.MainPage">
 <Grid RowDefinitions="*, Auto">

        <TabbedPage>
            <ContentPage>
                <!--General Settings-->
            </ContentPage>

            <ContentPage>
                <!--Production Environment Settings-->
            </ContentPage>

            <ContentPage>
                <!--Dev Environment Settings-->
            </ContentPage>
        </TabbedPage>

        <HorizontalStackLayout Grid.Row="1">
            <!--Buttons that are visible all the time-->
        </HorizontalStackLayout>
    </Grid>
</ContentPage>
  1. Run the Application in MS Code or in Release Mode with Visual Studio

Link to public reproduction project repository

No response

Version with bug

8.0.21 SR4.1

Is this a regression from previous behavior?

Yes, this used to work in .NET MAUI

Last version that worked well

Unknown/Other

Affected platforms

macOS

Affected platform versions

No response

Did you find any workaround?

No response

Relevant log output

2024-05-16 15:31:19.358 MyMauiApp[21498:10520592] You've implemented -[<UIApplicationDelegate> application:performFetchWithCompletionHandler:], but you still need to add "fetch" to the list of your supported UIBackgroundModes in your Info.plist.
2024-05-16 15:32:02.732 MyMauiApp[21498:10520592] 
Unhandled Exception:
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
 ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
 ---> System.InvalidOperationException: Parent of a Page must also be a Page
   at Microsoft.Maui.Controls.Page.OnParentSet()
   at Microsoft.Maui.Controls.Element.SetParent(Element value)
   at Microsoft.Maui.Controls.Element.OnChildAdded(Element child)
   at Microsoft.Maui.Controls.VisualElement.OnChildAdded(Element child)
   at Microsoft.Maui.Controls.Element.AddLogicalChild(Element element)
   at Microsoft.Maui.Controls.Layout.Add(IView child)
   at System.Reflection.MethodBaseInvoker.InterpretedInvoke_Method(Object obj, IntPtr* args)
   at System.Reflection.MethodBaseInvoker.InvokeDirectByRefWithFewArgs(Object obj, Span`1 copyOfArgs, BindingFlags invokeAttr)
   --- End of inner exception stack trace ---
   at Microsoft.Maui.C
ontrols.Xaml.ApplyPropertiesVisitor.SetPropertyValue(Object xamlelement, XmlName propertyName, Object value, Object rootElement, INode node, HydrationContext context, IXmlLineInfo lineInfo)
   at Microsoft.Maui.Controls.Xaml.ApplyPropertiesVisitor.Visit(ElementNode node, INode parentNode)
   at Microsoft.Maui.Controls.Xaml.ElementNode.Accept(IXamlNodeVisitor visitor, INode parentNode)
   at Microsoft.Maui.Controls.Xaml.ElementNode.Accept(IXamlNodeVisitor visitor, INode parentNode)
   at Microsoft.Maui.Controls.Xaml.RootNode.Accept(IXamlNodeVisitor visitor, INode parentNode)
   at Microsoft.Maui.Controls.Xaml.XamlLoader.Visit(RootNode rootnode, HydrationContext visitorContext, Boolean useDesignProperties)
   at Microsoft.Maui.Controls.Xaml.XamlLoader.Load(Object view, String xaml, Assembly rootAssembly, Boolean useDesignProperties)
   at Microsoft.Maui.Controls.Xaml.XamlLoader.Load(Object view, String xaml, Boolean useDesignProperties)
   at Microsoft.Maui.Controls.Xaml.XamlLoader.Load(Object view, Type callin
gType)
   at Microsoft.Maui.Controls.Xaml.Extensions.LoadFromXaml[MainPage](MainPage view, Type callingType)
   at MyMauiApp.MainPage.InitializeComponent() in /Users/xxx/Development/LotusMac/MyMauiApp/Microsoft.Maui.Controls.SourceGen/Microsoft.Maui.Controls.SourceGen.CodeBehindGenerator/MainPage.xaml.sg.cs:line 22
   at MyMauiApp.MainPage..ctor() in /Users/xxx/Development/LotusMac/MyMauiApp/MainPage.xaml.cs:line 9
   at System.Reflection.MethodBaseInvoker.InterpretedInvoke_Constructor(Object obj, IntPtr* args)
   at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr)
   --- End of inner exception stack trace ---
   at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr)
   at System.RuntimeType.CreateInstanceMono(Boolean nonPublic, Boolean wrapExceptions)
   at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean wrapExceptions)
   at System.Activator.CreateInstance(Type type, Boolean nonPublic, Boolean w
rapExceptions)
   at System.Activator.CreateInstance(Type type, Boolean nonPublic)
   at System.Activator.CreateInstance(Type type)
   at Microsoft.Maui.Controls.ShellContent.<>c__DisplayClass19_0.<Microsoft.Maui.Controls.IShellContentController.GetOrCreateContent>b__0()
   at Microsoft.Maui.Controls.ElementTemplate.CreateContent()
   at Microsoft.Maui.Controls.Internals.DataTemplateExtensions.CreateContent(DataTemplate self, Object item, BindableObject container)
   at Microsoft.Maui.Controls.ShellContent.Microsoft.Maui.Controls.IShellContentController.GetOrCreateContent()
   at Microsoft.Maui.Controls.Platform.Compatibility.ShellSectionRootRenderer.LoadRenderers()
   at Microsoft.Maui.Controls.Platform.Compatibility.ShellSectionRootRenderer.ViewDidLoad()
   at UIKit.UIApplication.UIApplicationMain(Int32 argc, String[] argv, IntPtr principalClassName, IntPtr delegateClassName) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/UIKit/UIApplication.cs:line 58
   at UIKit.UIApplication.Main(String[] args, Type
 principalClass, Type delegateClass) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/UIKit/UIApplication.cs:line 94
   at MyMauiApp.Program.Main(String[] args) in /Users/xxx/Development/LotusMac/MyMauiApp/Platforms/MacCatalyst/Program.cs:line 13
2024-05-16 15:32:02.736 MyMauiApp[21498:10520592] Unhandled managed exception: Exception has been thrown by the target of an invocation. (System.Reflection.TargetInvocationException)
   at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr)
   at System.RuntimeType.CreateInstanceMono(Boolean nonPublic, Boolean wrapExceptions)
   at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean wrapExceptions)
   at System.Activator.CreateInstance(Type type, Boolean nonPublic, Boolean wrapExceptions)
   at System.Activator.CreateInstance(Type type, Boolean nonPublic)
   at System.Activator.CreateInstance(Type type)
   at Microsoft.Maui.Controls.ShellContent.<>c__DisplayClass19_0.<Microsoft.Maui.Controls.IShellContentController.GetOrCreateContent>b__0()
   at Microsoft.Maui.Controls.ElementTemplate.CreateContent()
   at Microsoft.Maui.Controls.Internals.DataTemplateExtensions.CreateContent(DataTemplate self, Object item, BindableObject container)
   at Microsoft.M
aui.Controls.ShellContent.Microsoft.Maui.Controls.IShellContentController.GetOrCreateContent()
   at Microsoft.Maui.Controls.Platform.Compatibility.ShellSectionRootRenderer.LoadRenderers()
   at Microsoft.Maui.Controls.Platform.Compatibility.ShellSectionRootRenderer.ViewDidLoad()
   at UIKit.UIApplication.UIApplicationMain(Int32 argc, String[] argv, IntPtr principalClassName, IntPtr delegateClassName) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/UIKit/UIApplication.cs:line 58
   at UIKit.UIApplication.Main(String[] args, Type principalClass, Type delegateClass) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/UIKit/UIApplication.cs:line 94
   at MyMauiApp.Program.Main(String[] args) in /Users/xxx/Development/LotusMac/MyMauiApp/Platforms/MacCatalyst/Program.cs:line 13
Exception has been thrown by the target of an invocation. (System.Reflection.TargetInvocationException)
   at Microsoft.Maui.Controls.Xaml.ApplyPropertiesVisitor.SetPropertyValue(Object xamlelement, XmlName propertyName, Object val
ue, Object rootElement, INode node, HydrationContext context, IXmlLineInfo lineInfo)
   at Microsoft.Maui.Controls.Xaml.ApplyPropertiesVisitor.Visit(ElementNode node, INode parentNode)
   at Microsoft.Maui.Controls.Xaml.ElementNode.Accept(IXamlNodeVisitor visitor, INode parentNode)
   at Microsoft.Maui.Controls.Xaml.ElementNode.Accept(IXamlNodeVisitor visitor, INode parentNode)
   at Microsoft.Maui.Controls.Xaml.RootNode.Accept(IXamlNodeVisitor visitor, INode parentNode)
   at Microsoft.Maui.Controls.Xaml.XamlLoader.Visit(RootNode rootnode, HydrationContext visitorContext, Boolean useDesignProperties)
   at Microsoft.Maui.Controls.Xaml.XamlLoader.Load(Object view, String xaml, Assembly rootAssembly, Boolean useDesignProperties)
   at Microsoft.Maui.Controls.Xaml.XamlLoader.Load(Object view, String xaml, Boolean useDesignProperties)
   at Microsoft.Maui.Controls.Xaml.XamlLoader.Load(Object view, Type callingType)
   at Microsoft.Maui.Controls.Xaml.Extensions.LoadFromXaml[MainPage](MainPage view, Type callingTy
pe)
   at MyMauiApp.MainPage.InitializeComponent() in /Users/xxx/Development/LotusMac/MyMauiApp/Microsoft.Maui.Controls.SourceGen/Microsoft.Maui.Controls.SourceGen.CodeBehindGenerator/MainPage.xaml.sg.cs:line 22
   at MyMauiApp.MainPage..ctor() in /Users/xxx/Development/LotusMac/MyMauiApp/MainPage.xaml.cs:line 9
   at System.Reflection.MethodBaseInvoker.InterpretedInvoke_Constructor(Object obj, IntPtr* args)
   at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr)
Parent of a Page must also be a Page (System.InvalidOperationException)
   at Microsoft.Maui.Controls.Page.OnParentSet()
   at Microsoft.Maui.Controls.Element.SetParent(Element value)
   at Microsoft.Maui.Controls.Element.OnChildAdded(Element child)
   at Microsoft.Maui.Controls.VisualElement.OnChildAdded(Element child)
   at Microsoft.Maui.Controls.Element.AddLogicalChild(Element element)
   at Microsoft.Maui.Controls.Layout.Add(IView child)
   at System.Reflection.MethodBaseInvoker.InterpretedInvoke
_Method(Object obj, IntPtr* args)
   at System.Reflection.MethodBaseInvoker.InvokeDirectByRefWithFewArgs(Object obj, Span`1 copyOfArgs, BindingFlags invokeAttr)

=================================================================
	Native Crash Reporting
=================================================================
Got a SIGABRT while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries 
used by your application.
=================================================================

=================================================================
	Native stacktrace:
=================================================================
	0x100f137f0 - /Users/xxx/Development/LotusMac/MyMauiApp/bin/Debug/net8.0-maccatalyst/maccatalyst-arm64/MyMauiApp.app/Contents/MacOS/MyMauiApp : mono_dump_native_crash_info
	0x100ecc804 - /Users/xxx/Development/LotusMac/MyMauiApp/bin/Debug/net8.0-maccatalyst/maccatalyst-arm64/MyMauiApp.app/Contents/MacOS/MyMauiApp : mono_handle_native_crash
	0x101015980 - /Users/xxx/Development/LotusMac/MyMauiApp/bin/Debug/net8.0-maccatalyst/maccatalyst-arm64/MyMauiApp.app/Contents/MacOS/MyMauiApp : sigabrt_signal_handler.cold.1
	0x100f130b0 - /Users/xxx/Development/LotusMac/MyMauiApp/bin/Debug/net8.0-maccatalyst/maccatalyst-arm64/MyMauiApp.app/Contents/MacOS/MyMauiApp : mono_runtime_setup_stat_profiler
	0x1918e3584 - /usr/lib/system/libsystem_platform.dylib : _sigtramp
	0x1918b2c20 - /usr/lib/system/libsystem_pthread.dylib : pthread_kill
	0x1917bfa20 - /usr/lib/system/libsystem_c.dylib : abort
	0x100b5f3c0 - /Users/xxx/Development/LotusMac/MyMauiApp/bin/Debug/net8.0-maccatalyst/maccatalyst-arm64/MyMauiApp.app/Contents/MacOS/MyMauiApp : xamarin_find_protocol_wrapper_type
	0x100dbc0fc - /Users/xxx/Development/LotusMac/MyMauiApp/bin/Debug/net8.0-maccatalyst/maccatalyst-arm64/MyMauiApp.app/Contents/MacOS/MyMauiApp : mono_invoke_unhandled_exception_hook
	0x100eb049c - /Users/xxx/Development/LotusMac/MyMauiApp/bin/Debug/net8.0-maccatalyst/maccatalyst-arm64/MyMauiApp.app/Contents/MacOS/MyMauiApp : mono_jit_exec
	0x100b719b4 - /Users/xxx/Development/LotusMac/MyMauiApp/bin/Debug/net8.0-maccatalyst/maccatalyst-arm64/MyMauiApp.app/Contents/MacOS/MyMauiApp : xamarin_main
	0x1010154d0 - /Users/xxx/Development/LotusMac/MyMauiApp/bin/Debug/net8.0-maccatalyst/maccatalyst-arm64/MyMauiApp.app/Contents/MacOS/MyMauiApp : main
	0x19152a0e0 - /usr/lib/dyld : start

=================================================================
	Basic Fault Address Reporting
=================================================================
Memory around native instruction pointer (0x19187aa60):0x19187aa50  ff 0f 5f d6 c0 03 5f d6 10 29 80 d2 01 10 00 d4  .._..._..)......
0x19187aa60  03 01 00 54 7f 23 03 d5 fd 7b
bf a9 fd 03 00 91  ...T.#...{......
0x19187aa70  50 e0 ff 97 bf 03 00 91 fd 7b c1 a8 ff 0f 5f d6  P........{...._.
0x19187aa80  c0 03 5f d6 70 0a 80 d2 01 10 00 d4 03 01 00 54  .
._.p..........T

=================================================================
	Managed Stacktrace:
=================================================================
=================================================================

@svn2208 svn2208 added the t/bug Something isn't working label May 16, 2024
Copy link
Contributor

Hi I'm an AI powered bot that finds similar issues based off the issue title.

Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one and thumbs upping the other issue to help us prioritize it. Thank you!

Open similar issues:

Closed similar issues:

Note: You can give me feedback by thumbs upping or thumbs downing this comment.

@PureWeen
Copy link
Member

@svn2208 TabbedPage is a top level page control you can't add it to a grid.

If you want to use something that acts like a tabbedpage embedded in your grid than I'd recommend using a CarouselView and IndicatorView.

you can also try out https://github.com/roubachof/Sharpnado.Tabs

@samhouts samhouts added the platform/macOS 🍏 macOS / Mac Catalyst label May 24, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Jun 24, 2024
@samhouts samhouts added area-layout StackLayout, GridLayout, ContentView, AbsoluteLayout, FlexLayout, ContentPresenter layout-grid labels Aug 29, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-layout StackLayout, GridLayout, ContentView, AbsoluteLayout, FlexLayout, ContentPresenter layout-grid platform/macOS 🍏 macOS / Mac Catalyst t/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants