CommunityToolkit/WindowsCommunityToolkit

TypeLoadException in Release using Behaviors with an ICommand

Open

#4.022 geöffnet am 12. Mai 2021

Auf GitHub ansehen
 (6 Kommentare) (1 Reaktion) (0 zugewiesene Personen)C# (1.403 Forks)batch import
bug :bug:external :arrow_heading_up:help wanted

Repository-Metriken

Stars
 (5.708 Stars)
PR-Merge-Metriken
 (Keine gemergten PRs in 30 T)

Beschreibung

Describe the bug

Using a Behavior that has an ICommand property fails to run in Release build when using a standard Binding in XAML as such:

<Interactivity:Interaction.Behaviors>
    <Core:EventTriggerBehavior EventName="PointerPressed">
        <Core:InvokeCommandAction Command="{Binding TestCommand}" />
    </Core:EventTriggerBehavior>
</Interactivity:Interaction.Behaviors>

The exception is as follows:

Exception thrown at 0x755FA6E2 (KernelBase.dll) in CommandIssue.exe: WinRT originate error - 0x80131522 : 'System.TypeLoadException: Could not find Windows Runtime type 'System.Windows.Input.ICommand'.
   at System.StubHelpers.WinRTTypeNameConverter.GetTypeFromWinRTTypeName(String typeName, Boolean& isPrimitive)
   at System.StubHelpers.SystemTypeMarshaler.ConvertToManaged(TypeNameNative* pNativeType, Type& managedType)
   at Windows.UI.Xaml.Markup.IXamlType.get_UnderlyingType()
   at Microsoft.Toolkit.Uwp.UI.Controls.Core.Microsoft_Toolkit_Uwp_UI_Controls_Core_XamlTypeInfo.XamlTypeInfoProvider.GetXamlTypeBy'.
onecore\com\combase\winrt\error\restrictederror.cpp(1016)\combase.dll!764711A5: (caller: 76387BB6) ReturnHr(1) tid(10ec) 8007007E The specified module could not be found.
Exception thrown at 0x755FA6E2 (KernelBase.dll) in CommandIssue.exe: WinRT originate error - 0x802B000A : 'Cannot deserialize XBF metadata property list as 'Command' was not found in type 'Microsoft.Xaml.Interactions.Core.InvokeCommandAction'. [Line: 0 Position: 0]'.

This issue does not occur when the WCT is not referenced or if running the Debug build.

  • Is this bug a regression in the toolkit? If so, what toolkit version did you last see it work:

Steps to Reproduce

CommandIssue.zip

  • Can this be reproduced in the Sample App? (Either in a sample as-is or with new XAML pasted in the editor.) If so, please provide custom XAML or steps to reproduce. If not, let us know why it can't be reproduced (e.g. more complex setup, environment, dependencies, etc...)

Steps to reproduce the behavior:

  1. Given the following environment (Sample App w/ XAML)
  2. Build in the Release Configuration.
  3. Start debugging the application from Visual Studio (while still in Release Configuration).
  4. See error

Expected behavior

The exception does not occur and runs correctly.

Screenshots

Environment

NuGet Package(s): 
Microsoft.NETCore.UniversalWindowsPlatform (6.2.12)
Microsoft.Xaml.Behaviors.Uwp.Managed (2.0.1)
Microsoft.Toolkit.Uwp.UI.Controls (7.0.1)

Package Version(s): 

Windows 10 Build Number:
- [ ] Fall Creators Update (16299)
- [ ] April 2018 Update (17134)
- [ ] October 2018 Update (17763)
- [ ] May 2019 Update (18362)
- [X] May 2020 Update (19041)
- [ ] Insider Build (build number: )

App min and target version:
- [ ] Fall Creators Update (16299)
- [ ] April 2018 Update (17134)
- [ ] October 2018 Update (17763)
- [X] May 2019 Update (18362)
- [ ] May 2020 Update (19041)
- [ ] Insider Build (xxxxx)

Device form factor:
- [X] Desktop
- [ ] Xbox
- [ ] Surface Hub
- [ ] IoT

Visual Studio 
- [ ] 2017 (version: )
- [X] 2019 (version: 16.9.5) 
- [ ] 2019 Preview (version: )

Additional context

Add any other context about the problem here.

Contributor Guide