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

Failure to initialize App MainPage on startup after updating to RC1 #6063

Closed
trueip9 opened this issue Apr 13, 2022 · 9 comments
Closed

Failure to initialize App MainPage on startup after updating to RC1 #6063

trueip9 opened this issue Apr 13, 2022 · 9 comments
Labels
area-xaml XAML, CSS, Triggers, Behaviors platform/windows 🪟 s/triaged Issue has been reviewed t/bug Something isn't working
Milestone

Comments

@trueip9
Copy link

trueip9 commented Apr 13, 2022

Description

After updating to RC1 my existing MAUI app project builds successfully but fails to initialize main page and terminates start up.

Troubleshooting steps attempted:

  • Restart VS
  • Repair VS from installer
  • Clean build folder and re-build
  • Restart Windows
  • Delete project folder and clone again
  • Try using MainPage without wrapping into NavigationPage

Still no luck

Steps to Reproduce

  1. Update Visual Studio from 17.2.0 Preview 2.1 to Preview 3.0
  2. Open existing solution with MAUI project (where MainPage = new NavigationPage(new MainPage); (Inherited from ContentPage)
  3. Update NuGet packages (Microsoft.Graphics.Win2D and Microsoft.WindowsAppSDK)
  4. Build and run for Windows (debug, any cpu)

Version with bug

Release Candidate 1 (current)

Last version that worked well

Preview 14

Affected platforms

Windows

Affected platform versions

net6.0-windows10.0.19041

Did you find any workaround?

Fresh default project builds and runs normally.
Do not updete to RC1 if you already have project in development.

Relevant log output

System.Reflection.TargetInvocationException
  HResult=0x80131604
  Message=Exception has been thrown by the target of an invocation.
  Source=System.Private.CoreLib
  StackTrace:
   at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean wrapExceptions)
   at System.Activator.CreateInstance(Type type, Boolean nonPublic, Boolean wrapExceptions)
   at Microsoft.Maui.Controls.Xaml.CreateValuesVisitor.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[TXaml](TXaml view, Type callingType)
   at TrueIP_Configurator.MainPage.InitializeComponent() in C:\Users\sniko\source\repos\TrueIP_Configurator\TrueIP_Configurator\Microsoft.Maui.Controls.SourceGen\Microsoft.Maui.Controls.SourceGen.CodeBehindGenerator\MainPage.xaml.sg.cs:line 38
   at TrueIP_Configurator.MainPage..ctor() in C:\Users\sniko\source\repos\TrueIP_Configurator\TrueIP_Configurator\MainPage.xaml.cs:line 15
   at TrueIP_Configurator.App..ctor() in C:\Users\sniko\source\repos\TrueIP_Configurator\TrueIP_Configurator\App.xaml.cs:line 48
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Span`1& arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)
   at System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, RuntimeResolverContext context)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitRootCache(ServiceCallSite callSite, RuntimeResolverContext context)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.Resolve(ServiceCallSite callSite, ServiceProviderEngineScope scope)
   at Microsoft.Extensions.DependencyInjection.ServiceProvider.CreateServiceAccessor(Type serviceType)
   at System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory)
   at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(Type serviceType, ServiceProviderEngineScope serviceProviderEngineScope)
   at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(Type serviceType)
   at Microsoft.Maui.MauiContext.WrappedServiceProvider.GetService(Type serviceType)
   at Microsoft.Maui.MauiContext.WrappedServiceProvider.GetService(Type serviceType)
   at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider provider, Type serviceType)
   at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService[T](IServiceProvider provider)
   at Microsoft.Maui.MauiWinUIApplication.OnLaunched(LaunchActivatedEventArgs args)
   at TrueIP_Configurator.WinUI.App.OnLaunched(LaunchActivatedEventArgs args) in C:\Users\sniko\source\repos\TrueIP_Configurator\TrueIP_Configurator\Platforms\Windows\App.xaml.cs:line 26
   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)

  This exception was originally thrown at this call stack:
    [External Code]

Inner Exception 1:
InvalidOperationException: .ctor is currently not enabled. To enable compatibility features you will need to call add `builder.UseMauiCompatibility()`.

MauiApp
	.CreateBuilder()
	.UseMauiApp<TApp>()
	.UseMauiCompatibility();
@trueip9 trueip9 added s/needs-verification Indicates that this issue needs initial verification before further triage will happen t/bug Something isn't working labels Apr 13, 2022
@pekspro
Copy link

pekspro commented Apr 13, 2022

I had the following lines in my .csproj:

<PropertyGroup Condition="$(TargetFramework.Contains('-windows'))">
	<OutputType>WinExe</OutputType>
	<RuntimeIdentifier>win-x64</RuntimeIdentifier>
</PropertyGroup>

Removing this make my app start again without this exception. I also needed to update this SQLite reference to the latest preview:

<PackageReference Include="SQLitePCLRaw.bundle_e_sqlite3" Version="2.1.0-pre20220318192836" />

Maybe related: ericsink/SQLitePCL.raw#465

@Zetthard
Copy link

Might be relevant:
Three intances of "WMC100 Cannot resolve metadaata for WinUI types. Please ensure that Nuget Restore was sucessful." warnings started to appear in Error/Warning list console in VS after this update.

@trueip9
Copy link
Author

trueip9 commented Apr 14, 2022

Workaround has been found:
Remove xmlns:compat="clr-namespace:Microsoft.Maui.Controls.Compatibility;assembly=Microsoft.Maui.Controls" namespace and all controls using this namespace. It seems that issue has something to do with controls namespaces.
edit: I'm using RelativeLayout, that's why I need Compatibility namespace. Or should I refactor to avoid using this layout? Looks like issue is in RelativeLayout ctor.

@jfversluis jfversluis removed the s/needs-verification Indicates that this issue needs initial verification before further triage will happen label Apr 14, 2022
@PureWeen PureWeen added this to the 6.0.300-servicing milestone Apr 14, 2022
@VincentBu VincentBu added the s/triaged Issue has been reviewed label Jun 23, 2022
@VincentBu
Copy link

not repro with vs main build(32622.314)

@Redth Redth modified the milestones: 6.0-servicing, Backlog Aug 30, 2022
@ghost
Copy link

ghost commented Aug 30, 2022

We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.

@jfversluis
Copy link
Member

It has been a while since this was reported. I'm going to be optimistic and assume this has been fixed in newer versions. If there is still something wrong, please feel free to open a new issue. Thanks!

@jfversluis jfversluis closed this as not planned Won't fix, can't repro, duplicate, stale Mar 18, 2023
@ilsur-dev111
Copy link

@jfversluis Hi! In the latest version (currently version 7) the problem still exists when using RelativeLayout.

@jfversluis
Copy link
Member

Thanks for confirming @ilsur-dev111 I've linked it to this one, I'm pretty sure that will be the same root cause: #12748

@ghost ghost locked as resolved and limited conversation to collaborators Apr 19, 2023
@samhouts
Copy link
Member

samhouts commented Aug 4, 2023

#12748 (comment)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-xaml XAML, CSS, Triggers, Behaviors platform/windows 🪟 s/triaged Issue has been reviewed t/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

10 participants