ramirbrio
Topic Author
Posts: 6
Joined: 26 Apr 2022, 16:42

MultiBinding with custom converter

27 Apr 2022, 10:56

Hello, I always get an error on startup if I use my own converters:
MultiBinding converter failed to convert source values
But it works fine at runtime.

This xaml has an error:
    <UserControl.Resources>
        <ResourceDictionary>
            <converters:MultiplyConverter x:Key="multiplyConverter" />
        </ResourceDictionary>
    </UserControl.Resources>
    <StackPanel>
        <Rectangle
            x:Name="Rectangle2"
            Width="100"
            Height="100"
            Fill="#FF991919" />
        <Rectangle
            x:Name="Rectangle3"
            Width="2"
            Height="100"
            Fill="#FF991919" />
        <TextBlock Width="100" Height="20">
            <TextBlock.Text>
                <MultiBinding Converter="{StaticResource multiplyConverter}">
                    <Binding ElementName="Rectangle2" Path="Width" />
                    <Binding ElementName="Rectangle3" Path="Width" />
                </MultiBinding>
            </TextBlock.Text>
        </TextBlock>
    </StackPanel>
But this does not have an error:
    <StackPanel>
        <Rectangle
            x:Name="Rectangle2"
            Width="100"
            Height="100"
            Fill="#FF991919" />
        <Rectangle
            x:Name="Rectangle3"
            Width="2"
            Height="100"
            Fill="#FF991919" />
        <TextBlock Width="100" Height="20">
            <TextBlock.Text>
                <MultiBinding StringFormat="{}{0} x {1}">
                    <Binding ElementName="Rectangle2" Path="Width" />
                    <Binding ElementName="Rectangle3" Path="Width" />
                </MultiBinding>
            </TextBlock.Text>
        </TextBlock>
    </StackPanel>
How can I fix this errors?
 
User avatar
sfernandez
Site Admin
Posts: 2984
Joined: 22 Dec 2011, 19:20

Re: MultiBinding with custom converter

28 Apr 2022, 19:51

Do you have any other error/exception message related to the conversion?
That message should appear if your converter code produced an exception or if the returned type is not compatible with the expected target type.
 
ramirbrio
Topic Author
Posts: 6
Joined: 26 Apr 2022, 16:42

Re: MultiBinding with custom converter

04 May 2022, 10:31

No, I only have these errors that appear on play and stop Play Mode.

And the converter starts working only after errors. I put Debug.Log on the first line of the Convert method.
 
User avatar
sfernandez
Site Admin
Posts: 2984
Joined: 22 Dec 2011, 19:20

Re: MultiBinding with custom converter

04 May 2022, 21:27

Could you please attach the Visual Studio debugger to your Unity project and place a breakpoint in Extend.cs at MultiConverterConvert() function where the exceptions are catched: https://github.com/Noesis/Managed/blob/ ... d.cs#L2497

Let me know if it reaches that breakpoint.
 
ramirbrio
Topic Author
Posts: 6
Joined: 26 Apr 2022, 16:42

Re: MultiBinding with custom converter

05 May 2022, 09:58

I didn't reach the breakpoint at this line.

I stoped UnityLog and I have this stack trace if it helps you:
  at NoesisUnity.UnityLog (System.Int32 level, System.String message) [0x000cc] in D:\repos\gitlab\redesign\Library\PackageCache\com.noesis.noesisgui@36e5d70d8b\Runtime\NoesisUnity.cs:357 
  at Noesis.NoesisGUI_PINVOKE.BaseComponent_Release (System.IntPtr jarg1) [0x00000] in <b004b4282955404e8782c65a225b7356>:0 
  at Noesis.BaseComponent.Release (System.IntPtr cPtr) [0x00001] in D:\repos\gitlab\redesign\Library\PackageCache\com.noesis.noesisgui@36e5d70d8b\Runtime\API\Proxies\BaseComponent.cs:62 
  at Noesis.Extend.ReleasePending () [0x00023] in D:\repos\gitlab\redesign\Library\PackageCache\com.noesis.noesisgui@36e5d70d8b\Runtime\API\Core\Extend.cs:5473 
  at Noesis.Extend.Shutdown () [0x0013c] in D:\repos\gitlab\redesign\Library\PackageCache\com.noesis.noesisgui@36e5d70d8b\Runtime\API\Core\Extend.cs:91 
  at Noesis.Extend.OnDomainUnload (System.Object sender, System.EventArgs e) [0x00001] in D:\repos\gitlab\redesign\Library\PackageCache\com.noesis.noesisgui@36e5d70d8b\Runtime\API\Core\Extend.cs:36 
  at System.AppDomain.DoDomainUnload () [0x00000] in <695d1cc93cca45069c528c15c9fdd749>:0 
 
User avatar
sfernandez
Site Admin
Posts: 2984
Joined: 22 Dec 2011, 19:20

Re: MultiBinding with custom converter

12 May 2022, 17:14

That log helped, thanks, I was able to reproduce the problem.
I created ticket #2347 in our bugtracker and will fix it for the next release.
 
ramirbrio
Topic Author
Posts: 6
Joined: 26 Apr 2022, 16:42

Re: MultiBinding with custom converter

13 May 2022, 10:44

Thanks a lot, we look forward to the fix
 
LizzyFox
Posts: 4
Joined: 02 Nov 2023, 12:14

Re: MultiBinding with custom converter

15 Nov 2023, 16:32

In Noesis 3.2.2 this error still exists :(
 
User avatar
sfernandez
Site Admin
Posts: 2984
Joined: 22 Dec 2011, 19:20

Re: MultiBinding with custom converter

17 Nov 2023, 19:03

Are you getting the same error message "MultiBinding converter failed to convert source values" when entering play mode?
Is the callstack of the log the same as the one attached above? If not, could you please open a ticket in our bugtracker and provide that information.
Thanks.
 
LizzyFox
Posts: 4
Joined: 02 Nov 2023, 12:14

Re: MultiBinding with custom converter

18 Nov 2023, 16:59

Are you getting the same error message "MultiBinding converter failed to convert source values" when entering play mode?
Is the callstack of the log the same as the one attached above?
Yes.
[NOESIS/E] 'UILayoutMaskToVisibilityConverter' MultiBinding converter failed to convert source values
UnityEngine.Debug:LogError (object,UnityEngine.Object)
NoesisUnity:UnityLog (int,string) (at ./Library/PackageCache/com.noesis.noesisgui@4e761addad/Runtime/NoesisUnity.cs:363)
Noesis.BaseComponent:Release (intptr) (at ./Library/PackageCache/com.noesis.noesisgui@4e761addad/Runtime/API/Proxies/BaseComponent.cs:62)
Noesis.Extend:ReleasePending () (at ./Library/PackageCache/com.noesis.noesisgui@4e761addad/Runtime/API/Core/Extend.cs:6110)
Noesis.Extend:Shutdown () (at ./Library/PackageCache/com.noesis.noesisgui@4e761addad/Runtime/API/Core/Extend.cs:83)
Noesis.Extend:OnDomainUnload (object,System.EventArgs) (at ./Library/PackageCache/com.noesis.noesisgui@4e761addad/Runtime/API/Core/Extend.cs:36)
System.AppDomain:DoDomainUnload ()

Who is online

Users browsing this forum: camimamedov, Semrush [Bot] and 28 guests