microsoft-ui-xaml icon indicating copy to clipboard operation
microsoft-ui-xaml copied to clipboard

Attached property of type Thickness in a C++/WinRT Windows Runtime component throwing exception while consuming it from a C# WinUI3 project.

Open Ajith-GS opened this issue 9 months ago • 2 comments

Describe the bug

We have a C++/WinRT Windows Runtime component project that provides a custom button style and implements some custom attached properties of type double, ** Microsoft::UI::Xaml::Thickness, etc. The binding is used to get the attached property values within XAML-style template. The Windows Runtime component project is referenced from a C++ WinUI3 project, and we are able to consume the button style without any issue. The same Windows Runtime component project is consumed from a C# WinUI3 project with the help of a projection project, as mentioned in the following link: https://learn.microsoft.com/en-us/windows/apps/develop/platform/csharp-winrt/net-projection-from-cppwinrt-component We are able to consume the style from the Windows Runtime component project only if the usage of the custom attached property of type Microsoft::UI::Xaml::Thickness is removed from the XAML style template; otherwise, it throws an exception as follows:.

Exception thrown: 'System.NotImplementedException' in WinRT.Runtime.dll
WinRT information: Not implemented

Exception thrown: 'Microsoft.UI.Xaml.Markup.XamlParseException' in WinRT.Runtime.dll
WinRT information: Not implemented

Not implemented

XAML parsing failed.
  1. Why doesn't the attached property of type Thickness is not working in C# project while other types (int and double are checked so far)are working fine?
  2. Are we missing any code/resource that are necessary for the custom attached properties?

Any help is greatly appreciated. Thanks.

Steps to reproduce the bug

WinUI3CSharpTest.zip

Sample projects simulating the above scenario are attached(WinUI3CSharpTest.zip). The following projects are contained in the attached Zip files. TestResourceLib – C++\WinRT runtime component library. TestResourceLibCSharp - .NET C# language projection project of TestResourceLib. TestResourceCSharpApp – .NET test application that refers the TestResourceLibCSharp to use TestResourceLib in .NET application. TestResourceApp – C++\WinRT test application that uses TestResourceLib directly.

  1. Unzip and open the solution in Visual Studio.
  2. Build the solution in Debug or Release x64 configuration.
  3. Set TestResourceCSharpApp as startup project and run the project.

Expected behavior

C# Application should able to consume the styles and sources from C++ WinRT runtime project without any exception.

Screenshots

Call Stack Callstck Output Message ErrorLog

No response

NuGet package version

Windows App SDK 1.5.3: 1.5.240428000

Packaging type

Packaged (MSIX)

Windows version

Windows 10 version 22H2 (19045, 2022 Update)

IDE

Visual Studio 2022

Additional context

No response

Ajith-GS avatar May 24 '24 13:05 Ajith-GS