Page 1 of 2

MultiBinding with custom converter

Posted: 27 Apr 2022, 10:56
by ramirbrio
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?

Re: MultiBinding with custom converter

Posted: 28 Apr 2022, 19:51
by sfernandez
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.

Re: MultiBinding with custom converter

Posted: 04 May 2022, 10:31
by ramirbrio
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.

Re: MultiBinding with custom converter

Posted: 04 May 2022, 21:27
by sfernandez
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.

Re: MultiBinding with custom converter

Posted: 05 May 2022, 09:58
by ramirbrio
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 

Re: MultiBinding with custom converter

Posted: 12 May 2022, 17:14
by sfernandez
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.

Re: MultiBinding with custom converter

Posted: 13 May 2022, 10:44
by ramirbrio
Thanks a lot, we look forward to the fix

Re: MultiBinding with custom converter

Posted: 15 Nov 2023, 16:32
by LizzyFox
In Noesis 3.2.2 this error still exists :(

Re: MultiBinding with custom converter

Posted: 17 Nov 2023, 19:03
by sfernandez
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.

Re: MultiBinding with custom converter

Posted: 18 Nov 2023, 16:59
by LizzyFox
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 ()