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

Control library project references doesn't work in single-project apps #6028

Closed
dotMorten opened this issue Oct 1, 2021 · 4 comments
Closed
Labels
bug Something isn't working Crash whenever user reports a crash or app freeze product-winui3 WinUI 3 issues team-Markup Issue for the Markup team

Comments

@dotMorten
Copy link
Contributor

Describe the bug
If you create a class library with WinUI controls and reference them with a project reference, the app runs fine with WAP project, but crashes at startup when using a single-project app.

Microsoft.UI.Xaml.Markup.XamlParseException: 'XAML parsing failed.'
Inspecting the error doesn't lead to any more info in additional details, and since control works fine in a packaged project, I'm confident the XAML is ok.

Stack:

 	WinRT.Runtime.dll!WinRT.ExceptionHelpers.ThrowExceptionForHR(int hr)	Unknown
 	Microsoft.WinUI.dll!ABI.Microsoft.UI.Xaml.IApplicationStatics.Microsoft.UI.Xaml.IApplicationStatics.LoadComponent(object component, System.Uri resourceLocator, Microsoft.UI.Xaml.Controls.Primitives.ComponentResourceLocation componentResourceLocation)	Unknown
 	Microsoft.WinUI.dll!Microsoft.UI.Xaml.Application.LoadComponent(object component, System.Uri resourceLocator, Microsoft.UI.Xaml.Controls.Primitives.ComponentResourceLocation componentResourceLocation)	Unknown
>	SampleApp.dll!SampleApp.MainWindow.InitializeComponent() Line 39	C#
 	SampleApp.dll!SampleApp.MainWindow.MainWindow() Line 28	C#
 	SampleApp.dll!SampleApp.App.OnLaunched(Microsoft.UI.Xaml.LaunchActivatedEventArgs args) Line 45	C#
 	Microsoft.WinUI.dll!Microsoft.UI.Xaml.Application.Microsoft.UI.Xaml.IApplicationOverrides.OnLaunched(Microsoft.UI.Xaml.LaunchActivatedEventArgs args)	Unknown
 	Microsoft.WinUI.dll!ABI.Microsoft.UI.Xaml.IApplicationOverrides.Do_Abi_OnLaunched_0(System.IntPtr thisPtr, System.IntPtr args)	Unknown
 	[Native to Managed Transition]	
 	Microsoft.ui.xaml.dll!DirectUI::FrameworkApplicationGenerated::OnLaunchedProtected()	Unknown
 	Microsoft.ui.xaml.dll!DirectUI::FrameworkApplication::InvokeOnLaunchActivated()	Unknown
 	Microsoft.ui.xaml.dll!DirectUI::FrameworkApplication::StartOnCurrentThreadImpl()	Unknown
 	Microsoft.ui.xaml.dll!DirectUI::FrameworkApplicationGenerated::StartOnCurrentThread()	Unknown
 	Microsoft.ui.xaml.dll!DirectUI::WindowsXamlManager::XamlCore::Initialize()	Unknown
 	Microsoft.ui.xaml.dll!DirectUI::WindowsXamlManager::Initialize()	Unknown
 	Microsoft.ui.xaml.dll!ctl::ComObjectBase::CreateInstanceBase()	Unknown
 	Microsoft.ui.xaml.dll!ctl::ComObject<DirectUI::WindowsXamlManager>::CreateInstance<DirectUI::WindowsXamlManager>()	Unknown
 	Microsoft.ui.xaml.dll!ctl::make<class DirectUI::WindowsXamlManager>(class ctl::Internal::ComPtrRef<class ctl::ComPtr<class DirectUI::WindowsXamlManager> >)	Unknown
 	Microsoft.ui.xaml.dll!DirectUI::WindowsXamlManagerFactory::InitializeForCurrentThreadImpl()	Unknown
 	Microsoft.ui.xaml.dll!DirectUI::WindowsXamlManagerFactory::InitializeForCurrentThread()	Unknown
 	Microsoft.ui.xaml.dll!DirectUI::FrameworkApplicationFactory::Start()	Unknown

Steps to reproduce the bug

  1. Unzip reproducer: MyControlsLibrary.zip
  2. Open solution, and run "Sample app"
  3. Observe exception.

The same app in a WAP project does not crash but renders the custom control just fine. Also if you package the library into a nuget package and reference that, it does work fine. So it's an issue caused by a mix of project references and single-project builds.

Expected behavior
App runs same way as with WAP

Screenshots
image

Version Info
Win11

NuGet package version:
1.0.0-preview1

Additional context

This makes it impossible to use a unit test framework to run tests against control libraries.

@dotMorten dotMorten changed the title Control libs references doesn't work in single-project apps Control library project references doesn't work in single-project apps Oct 1, 2021
@btueffers btueffers transferred this issue from microsoft/WindowsAppSDK Oct 4, 2021
@ghost ghost added the needs-triage Issue needs to be triaged by the area owners label Oct 4, 2021
@gabbybilka
Copy link
Member

@marb2000 as FYI

@StephenLPeters StephenLPeters added area-NugetPackage Issue with the nuget package developer experience (e.g. build error, missing files) team-Markup Issue for the Markup team labels Oct 20, 2021
@StephenLPeters
Copy link
Contributor

@evelynwu-msft Thoughts?

@marb2000
Copy link
Contributor

I think this is a known issue to be fixed, right, @codendone and @MikeHillberg?

@evelynwu-msft evelynwu-msft added bug Something isn't working Crash whenever user reports a crash or app freeze product-winui3 WinUI 3 issues and removed area-NugetPackage Issue with the nuget package developer experience (e.g. build error, missing files) labels Oct 18, 2022
@bpulliam bpulliam removed the needs-triage Issue needs to be triaged by the area owners label Dec 6, 2022
@evelynwu-msft
Copy link
Contributor

@dotMorten I updated your repro project to WinAppSDK 1.3 (since 1.0 Preview 1 is pretty old and there have been a lot of changes since then) and the app ran without issue. Feel free to reopen this if the crash is still occurring for you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Crash whenever user reports a crash or app freeze product-winui3 WinUI 3 issues team-Markup Issue for the Markup team
Projects
None yet
Development

No branches or pull requests

6 participants