microsoft / microsoft-ui-xaml

Windows UI Library: the latest Windows 10 native controls and Fluent styles for your applications
MIT License
6.37k stars 680 forks source link

Debug build failing for XAML Island hosted application in latest Windows 10 SDK versions #6878

Closed AndreasErikCoder closed 1 year ago

AndreasErikCoder commented 2 years ago

Describe the bug

When trying to build the solution in Debug mode with Windows SDK 10.0.19041.0 or 10.0.20348.0, build fails with below mentioned errors. However, build succeeds in Release mode (10.0.19041.0 or 10.0.20348.0) as well as with 10.0.18362.0 (both release and debug).

Errors obtained are:

Error C2259 'winrt::TestUWP_Dll::implementation::XamlMetaDataProvider': cannot instantiate abstract class (compiling source file App.cpp) TestUWP_DllC:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.31.31103\include\xmemory 1924

Error C2259 'winrt::TestUWP_Dll::implementation::XamlMetaDataProvider': cannot instantiate abstract class (compiling source file F:\MileStone_VS2022\Test\obj\x64\Debug\TestUWP_Dll\Generated Files\module.g.cpp) TestUWP_DllC:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.31.31103\include\xmemory 1924

Error MSB4181 The "CompileXaml" task returned false but did not log an error. TestUWP_DllC:\Program Files (x86)\Windows Kits\10\bin\10.0.19041.0\XamlCompiler\Microsoft.Windows.UI.Xaml.Common.targets 486

Severity Code Description Project File Line Suppression State Error MSB4018 The "GenerateWinRTManifestFromAppx" task failed unexpectedly. System.IO.FileNotFoundException: Could not find file 'F:\MileStone_VS2022\Test\bin\x64\Debug\TestUWP_Dll\AppxManifest.xml'. File name: 'F:\MileStone_VS2022\Test\bin\x64\Debug\TestUWP_Dll\AppxManifest.xml' at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost) at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize) at System.Xml.XmlDownloadManager.GetStream(Uri uri, ICredentials credentials, IWebProxy proxy, RequestCachePolicy cachePolicy) at System.Xml.XmlUrlResolver.GetEntity(Uri absoluteUri, String role, Type ofObjectToReturn) at System.Xml.XmlTextReaderImpl.OpenUrlDelegate(Object xmlResolver) at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData) at System.Threading.CompressedStack.Run(CompressedStack compressedStack, ContextCallback callback, Object state) at System.Xml.XmlTextReaderImpl.OpenUrl() at System.Xml.XmlTextReaderImpl.Read() at System.Xml.XmlLoader.Load(XmlDocument doc, XmlReader reader, Boolean preserveWhitespace) at System.Xml.XmlDocument.Load(XmlReader reader) at System.Xml.XmlDocument.Load(String filename) at InlineCode.GenerateWinRTManifestFromAppx.Execute() in c:\Users\User\AppData\Local\Temp\tufe5rqs.0.cs:line 91 at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute() at Microsoft.Build.BackEnd.TaskBuilder.d__26.MoveNext() TestMFC_Dll F:\MileStone_VS2022\Test\packages\Microsoft.Toolkit.Win32.UI.SDK.6.1.2\build\Microsoft.WinRT.Win32.targets 207

Steps to reproduce the bug

The main components of the solution are:

A hosting helper project which hosts application with C++/WinRT and XAML Island MFC application project While building the XAML island hosting project in debug mode the aforementioned errors are obtained.

Windows OS version: 21H1 OS Build: 19043.1586 Visual Studio Versions: 16, 17 Windows SDK: 10.0.19041.0, 10.0.20348.0

Expected behavior

Build should happen successfully in both Release and Debug mode with Windows SDK 10.0.19041.0 and 10.0.20348.0.

Screenshots

No response

NuGet package version

No response

Windows app type

Device form factor

No response

Windows version

Windows 10 (21H1): Build 19043

Additional context

No response

DeepthiCG commented 2 years ago

Same issue reproducible here also.

This is reported in below link, but not found any replies. https://techcommunity.microsoft.com/t5/windows-dev-appconsult/host-custom-uwp-controls-in-mfc-mdi-project-using-xaml-islands/bc-p/2853092/highlight/true#M579

AndreasErikCoder commented 2 years ago

@oldnewthing Could this error be related to the issue mentioned in your blog here

I tried adding the header file "winrt/Windows.UI.Xaml.Markup.h" but in vain.

github-actions[bot] commented 1 year ago

This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 5 days.