In xamarin forms 4.2 pre 3 I get this exception:
Xamarin.Forms.Xaml.XamlParseException: 'Position 60:67. Can not find the object referenced by OrderList'
the exception is related to the binding to a reference. Like this line:
ColumnDefinition Width="{Binding Source={x:Reference Name=OrderList}, Path=BindingContext.IsLocationDeleteVisible, Converter={StaticResource VariableGridLengthConverter}, ConverterParameter=OrderColumn1}"
Commenting this line out I get the exception in other lines containing a reference.
It is working with XF 4.2 pre 2 and earlier (3.x).
IDE:
Microsoft Visual Studio Professional 2019
Version 16.2.1
VisualStudio.16.Release/16.2.1+29201.188
Microsoft .NET Framework
Version 4.7.03056
Platform Target Frameworks:
Is part of a big project. Which is not applied here.
Thanks for the report @pskofod.
I see you can't add the whole project, but would it be possible to lift all the relevant code? Just this line doesn't tell us much. If you could put it in a project that would show this issue that would even be better.
Thanks!
The whole xaml file is here:
As far as I can tell this should be a similar structure to what you have in your XAML and it seems to work just fine. Could you please try this and add anything that I might have missed so it resembles your implementation better?
Hi Gerald.
Thanks for your fast answer. That's true in your setup it works. I also tried to make it even more similar to mine - and it still works.
One thing that is different for the two projects are the Nugets used.
In mine:
PackageReference Include="Xamarin.Android.Support.Design" Version="28.0.0.1"
PackageReference Include="Xamarin.Android.Support.v7.AppCompat" Version="28.0.0.1"
PackageReference Include="Xamarin.Android.Support.v4" Version="28.0.0.1"
PackageReference Include="Xamarin.Android.Support.v7.CardView" Version="28.0.0.1"
PackageReference Include="Xamarin.Android.Support.v7.MediaRouter" Version="28.0.0.1"
In yours is:
PackageReference Include="Xamarin.Android.Support.Core.Utils" Version 28.0.0.1
I couldn't just change my project to Xamarin.Android.Support.Core.Utils it gave conflicts. But I tried to migrate to AndroidX, which works fine for Pre2 but still gives the same error for pre 3.
I'm uncertain of which step to take now.
Cheers
Peter
@pskofod
Can you try testing against the latest nightly? https://github.com/xamarin/Xamarin.Forms/wiki/Nightly-Builds
If it's that specific XAML page causing issues can you
I'm also pinging @StephaneDelcroix in case there's something that rings a bell with him and this issue
I whittled your sample down myself a bit and I'm able to compile the OrderListPage you created without any issue
I'm not able to run it in any useable way because of missing staticresources but even then I tried to remove all of them except what you referenced above and in that instance I was able to compile and run the application without any issues
I have the same issue as @pskofod basically exact similar code is the culprit. Hope this is fixed soon :)
@michaeldimoudis please provide a reproduction project (self contained, a few xaml files only), and that'll speed up the process
@StephaneDelcroix it's basically exactly the same code as the 2 zip files above, however I'll send another snippet of my issue. It crashes in other areas in my app with similar code too.
crash issue 7097.xaml.zip
When I have more time I'll try get a full repro over to you instead of a file.
Using 4.2 stable I'm getting an runtime exception whereby binding to x:Referenced elements on the same page is not found.
The error I'm getting is:
Xamarin.Forms.Xaml.XamlParseException
Position 54:10. Can not find the object referenced by root
for:
Command="{Binding Source={x:Reference root}, Path=BindingContext.DeleteTimeCommand}"
where 'root' is the x:Name of the Page.
Downgrading to latest 4.1 solves the problem.
Nuget: 4.2.0.709249
I create small project with reproduced problem. Exception is thrown on Android and iOS. On UWP only blank items in CollectionView are displayed.
When i have only one page MainPage : ContentPage, it works. But when i add some inheritance to pages, exception is thrown (in example below)
Android exception:
08-23 06:30:29.271 I/MonoDroid(22558): UNHANDLED EXCEPTION:
08-23 06:30:29.276 I/MonoDroid(22558): Xamarin.Forms.Xaml.XamlParseException: Position 28:29. Can not find the object referenced byself
08-23 06:30:29.276 I/MonoDroid(22558): at (wrapper dynamic-method) Android.Runtime.DynamicMethodNameCounter.50(intptr,intptr,intptr,int)
08-23 06:30:29.276 I/MonoDroid(22558): at (wrapper native-to-managed) Android.Runtime.DynamicMethodNameCounter.50(intptr,intptr,intptr,int)
08-23 06:30:29.276 I/MonoDroid(22558): at (wrapper managed-to-native) Java.Interop.NativeMethods.java_interop_jnienv_call_nonvirtual_void_method_a(intptr,intptr&,intptr,intptr,intptr,Java.Interop.JniArgumentValue*)
08-23 06:30:29.276 I/MonoDroid(22558): at Java.Interop.JniEnvironment+InstanceMethods.CallNonvirtualVoidMethod (Java.Interop.JniObjectReference instance, Java.Interop.JniObjectReference type, Java.Interop.JniMethodInfo method, Java.Interop.JniArgumentValue* args) [0x00073] in <23e57773773243b6853e76fc01957c33>:0
08-23 06:30:29.276 I/MonoDroid(22558): at Java.Interop.JniPeerMembers+JniInstanceMethods.InvokeVirtualVoidMethod (System.String encodedMember, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue* parameters) [0x0005d] in <23e57773773243b6853e76fc01957c33>:0
08-23 06:30:29.276 I/MonoDroid(22558): at Android.Support.V7.Widget.RecyclerView.OnLayout (System.Boolean changed, System.Int32 l, System.Int32 t, System.Int32 r, System.Int32 b) [0x00079] in <7d32f6ecea2f48a59f0d551b445680b3>:0
08-23 06:30:29.276 I/MonoDroid(22558): at Xamarin.Forms.Platform.Android.ItemsViewRenderer.OnLayout (System.Boolean changed, System.Int32 l, System.Int32 t, System.Int32 r, System.Int32 b) [0x00000] in D:\a\1\s\Xamarin.Forms.Platform.Android\CollectionView\ItemsViewRenderer.cs:60
08-23 06:30:29.276 I/MonoDroid(22558): at Android.Support.V7.Widget.RecyclerView.n_OnLayout_ZIIII (System.IntPtr jnienv, System.IntPtr native__this, System.Boolean changed, System.Int32 l, System.Int32 t, System.Int32 r, System.Int32 b) [0x00008] in <7d32f6ecea2f48a59f0d551b445680b3>:0
08-23 06:30:29.276 I/MonoDroid(22558): at (wrapper dynamic-method) Android.Runtime.DynamicMethodNameCounter.42(intptr,intptr,bool,int,int,int,int)
**Xamarin.Forms.Xaml.XamlParseException:** 'Position 28:29. Can not find the object referenced byself'
iOS exception:
Xamarin.Forms.Xaml.XamlParseException: Position 28:29. Can not find the object referenced byself
at Xamarin.Forms.Xaml.ReferenceExtension.ProvideValue (System.IServiceProvider serviceProvider) [0x000bf] in D:\a\1\s\Xamarin.Forms.Xaml\MarkupExtensions\ReferenceExtension.cs:42
at XamlBindingReferenceApp.MainPage+<InitializeComponent>_anonXamlCDataTemplate_1.LoadDataTemplate () [0x00204] in <c119108e167f478a8a3c1e853eae6a32>:0
at Xamarin.Forms.ElementTemplate.CreateContent () [0x00026] in D:\a\1\s\Xamarin.Forms.Core\ElementTemplate.cs:82
at Xamarin.Forms.Platform.iOS.ItemsViewController.ApplyTemplateAndDataContext (Xamarin.Forms.Platform.iOS.TemplatedCell cell, Foundation.NSIndexPath indexPath) [0x00024] in D:\a\1\s\Xamarin.Forms.Platform.iOS\CollectionView\ItemsViewController.cs:218
at Xamarin.Forms.Platform.iOS.ItemsViewController.UpdateTemplatedCell (Xamarin.Forms.Platform.iOS.TemplatedCell cell,
Foundation.NSIndexPath indexPath) [0x00000] in D:\a\1\s\Xamarin.Forms.Platform.iOS\CollectionView\ItemsViewController.cs:191
at Xamarin.Forms.Platform.iOS.ItemsViewController.GetCell (UIKit.UICollectionView collectionView, Foundation.NSIndexPath indexPath) [0x0003b] in D:\a\1\s\Xamarin.Forms.Platform.iOS\CollectionView\ItemsViewController.cs:106
at Xamarin.Forms.Platform.iOS.ItemsViewController.GetPrototype () [0x0005d] in D:\a\1\s\Xamarin.Forms.Platform.iOS\CollectionView\ItemsViewController.cs:305
at Xamarin.Forms.Platform.iOS.ItemsViewLayout.DetermineCellSize () [0x00025] in D:\a\1\s\Xamarin.Forms.Platform.iOS\CollectionView\ItemsViewLayout.cs:204
at Xamarin.Forms.Platform.iOS.ListViewLayout.ConstrainTo (CoreGraphics.CGSize size) [0x0001e] in D:\a\1\s\Xamarin.Forms.Platform.iOS\CollectionView\ListViewLayout.cs:16
at Xamarin.Forms.Platform.iOS.ItemsViewController.ViewWillLayoutSubviews () [0x0000e] in D:\a\1\s\Xamarin.Forms.Platform.iOS\CollectionView\ItemsViewController.cs:151
at (wrapper
managed-to-native) UIKit.UIApplication.UIApplicationMain(int,string[],intptr,intptr)
at UIKit.UIApplication.Main (System.String[] args, System.IntPtr principal, System.IntPtr delegate) [0x00005] in /Library/Frameworks/Xamarin.iOS.framework/Versions/12.14.0.114/src/Xamarin.iOS/UIKit/UIApplication.cs:86
at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x0000e] in /Library/Frameworks/Xamarin.iOS.framework/Versions/12.14.0.114/src/Xamarin.iOS/UIKit/UIApplication.cs:65
at XamlBindingReferenceApp.iOS.Application.Main (System.String[] args) [0x00001] in C:\Users\MMarecek\source\repos\XamlBindingReferenceApp\XamlBindingReferenceApp\XamlBindingReferenceApp.iOS\Main.cs:17
2019-08-23 06:29:33.224301+0200 XamlBindingReferenceApp.iOS[48837:2120553] Unhandled managed exception: Position 28:29. Can not find the object referenced byself(Xamarin.Forms.Xaml.XamlParseException)
at Xamarin.Forms.Xaml.ReferenceExtension.ProvideValue (System.IServ
iceProvider serviceProvider) [0x000bf] in D:\a\1\s\Xamarin.Forms.Xaml\MarkupExtensions\ReferenceExtension.cs:42
at XamlBindingReferenceApp.MainPage+<InitializeComponent>_anonXamlCDataTemplate_1.LoadDataTemplate () [0x00204] in <c119108e167f478a8a3c1e853eae6a32>:0
at Xamarin.Forms.ElementTemplate.CreateContent () [0x00026] in D:\a\1\s\Xamarin.Forms.Core\ElementTemplate.cs:82
at Xamarin.Forms.Platform.iOS.ItemsViewController.ApplyTemplateAndDataContext (Xamarin.Forms.Platform.iOS.TemplatedCell cell, Foundation.NSIndexPath indexPath) [0x00024] in D:\a\1\s\Xamarin.Forms.Platform.iOS\CollectionView\ItemsViewController.cs:218
at Xamarin.Forms.Platform.iOS.ItemsViewController.UpdateTemplatedCell (Xamarin.Forms.Platform.iOS.TemplatedCell cell, Foundation.NSIndexPath indexPath) [0x00000] in D:\a\1\s\Xamarin.Forms.Platform.iOS\CollectionView\ItemsViewController.cs:191
at Xamarin.Forms.Platform.iOS.ItemsViewController.GetCell (UIKit.UICollectionView collectionView, Foundation.NSIndexPath indexPath) [0x000
3b] in D:\a\1\s\Xamarin.Forms.Platform.iOS\CollectionView\ItemsViewController.cs:106
at Xamarin.Forms.Platform.iOS.ItemsViewController.GetPrototype () [0x0005d] in D:\a\1\s\Xamarin.Forms.Platform.iOS\CollectionView\ItemsViewController.cs:305
at Xamarin.Forms.Platform.iOS.ItemsViewLayout.DetermineCellSize () [0x00025] in D:\a\1\s\Xamarin.Forms.Platform.iOS\CollectionView\ItemsViewLayout.cs:204
at Xamarin.Forms.Platform.iOS.ListViewLayout.ConstrainTo (CoreGraphics.CGSize size) [0x0001e] in D:\a\1\s\Xamarin.Forms.Platform.iOS\CollectionView\ListViewLayout.cs:16
at Xamarin.Forms.Platform.iOS.ItemsViewController.ViewWillLayoutSubviews () [0x0000e] in D:\a\1\s\Xamarin.Forms.Platform.iOS\CollectionView\ItemsViewController.cs:151
at (wrapper managed-to-native) UIKit.UIApplication.UIApplicationMain(int,string[],intptr,intptr)
at UIKit.UIApplication.Main (System.String[] args, System.IntPtr principal, System.IntPtr delegate) [0x00005] in /Library/Frameworks/Xamarin.iOS.framework/Versions/12.14.0.114/sr
c/Xamarin.iOS/UIKit/UIApplication.cs:86
at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x0000e] in /Library/Frameworks/Xamarin.iOS.framework/Versions/12.14.0.114/src/Xamarin.iOS/UIKit/UIApplication.cs:65
at XamlBindingReferenceApp.iOS.Application.Main (System.String[] args) [0x00001] in C:\Users\MMarecek\source\repos\XamlBindingReferenceApp\XamlBindingReferenceApp\XamlBindingReferenceApp.iOS\Main.cs:17
if this regression happened between -pre2 and -pre3, it's probably due to #7040
I have the same problem in Version="4.2.0.709249", was working on Version="4.2.0.608146-pre1"
Most helpful comment
Using 4.2 stable I'm getting an runtime exception whereby binding to x:Referenced elements on the same page is not found.
The error I'm getting is:
Xamarin.Forms.Xaml.XamlParseException
Position 54:10. Can not find the object referenced by
rootfor:
Command="{Binding Source={x:Reference root}, Path=BindingContext.DeleteTimeCommand}"
where 'root' is the x:Name of the Page.
Downgrading to latest 4.1 solves the problem.