Skip to content

BindingContextProvider throws exception in Unity2023 #53

Closed
@Hellfim

Description

@Hellfim

Simple declaration of BindingContextProvider

<UnityMvvmToolkit.UITK.BindableUIElements.BindingContextProvider name="TestName"/>

Throws an exception in runtime when BindingContextProvider is created. As far as I was able to trace the problem - method Deserialize of BindingContextProvider receives a visualElement argument which is being cast to BindingContextProvider inside .As method extension, which throws an exception. Received argument has a type of VisualElement.

Stacktrace (truncated my invocation entry-point):
InvalidCastException: Specified cast is not valid.
(wrapper castclass) System.Object.__castclass_with_cache(object,intptr,intptr)
UnityMvvmToolkit.UITK.Extensions.VisualElementExtensions.As[T] (System.Object visualElement) (at ./Library/PackageCache/com.chebanovdd.unitymvvmtoolkit@1.1.7/Runtime/UITK/Extensions/VisualElementExtensions.Uxml.cs:12)
UnityMvvmToolkit.UITK.BindableUIElements.BindingContextProvider1+UxmlSerializedData[TBindingContext].Deserialize (System.Object visualElement) (at ./Library/PackageCache/com.chebanovdd.unitymvvmtoolkit@1.1.7/Runtime/UITK/BindableUIElements/Uxmls/BindingContextProvider.T.Uxml.cs:23) UnityEngine.UIElements.VisualElementAsset.Instantiate (UnityEngine.UIElements.CreationContext cc) (at <844b3559a9bf433db5c9639bc6cc5f04>:0) UnityEngine.UIElements.VisualTreeAsset.Create (UnityEngine.UIElements.VisualElementAsset asset, UnityEngine.UIElements.CreationContext ctx) (at <844b3559a9bf433db5c9639bc6cc5f04>:0) UnityEngine.UIElements.VisualTreeAsset.CloneSetupRecursively (UnityEngine.UIElements.VisualElementAsset root, System.Collections.Generic.Dictionary2[TKey,TValue] idToChildren, UnityEngine.UIElements.CreationContext context) (at <844b3559a9bf433db5c9639bc6cc5f04>:0)
UnityEngine.UIElements.VisualTreeAsset.CloneSetupRecursively (UnityEngine.UIElements.VisualElementAsset root, System.Collections.Generic.Dictionary`2[TKey,TValue] idToChildren, UnityEngine.UIElements.CreationContext context) (at <844b3559a9bf433db5c9639bc6cc5f04>:0)
UnityEngine.UIElements.VisualTreeAsset.CloneTree (UnityEngine.UIElements.VisualElement target, UnityEngine.UIElements.CreationContext cc) (at <844b3559a9bf433db5c9639bc6cc5f04>:0)
UnityEngine.UIElements.VisualTreeAsset.Instantiate () (at <844b3559a9bf433db5c9639bc6cc5f04>:0)
UnityEngine.UIElements.UIDocument.RecreateUI () (at <844b3559a9bf433db5c9639bc6cc5f04>:0)
UnityEngine.UIElements.UIDocument.set_visualTreeAsset (UnityEngine.UIElements.VisualTreeAsset value) (at <844b3559a9bf433db5c9639bc6cc5f04>:0)

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions