I am trying to add a pin to my Xamarin Forms Mapsui control.
Here is my Xaml
<mapsui:MapView x:Name="selectMapControl"
VerticalOptions="FillAndExpand"
HorizontalOptions="Fill"
BackgroundColor="Gray" />
Here is my code:
protected override void OnAppearing()
{
base.OnAppearing();
var map = new Map
{
CRS = "EPSG:3857",
Transformation = new MinimalTransformation()
};
var tileLayer = OpenStreetMap.CreateTileLayer();
map.Layers.Add(tileLayer);
map.Widgets.Add(new Mapsui.Widgets.ScaleBar.ScaleBarWidget(map) { TextAlignment = Mapsui.Widgets.Alignment.Center, HorizontalAlignment = Mapsui.Widgets.HorizontalAlignment.Left, VerticalAlignment = Mapsui.Widgets.VerticalAlignment.Bottom });
selectMapControl.Map = map;
double lat = 36.9628066;
double lng = -122.0194722;
var myPosition = new Position(lat, lng);
var myPin = new Pin(selectMapControl) //Exception here
{
Position = myPosition,
Type = PinType.Pin,
Label = "Zero point",
Address = "Zero point",
};
selectMapControl.Pins.Add(myPin);
}
I receive an "Object reference not set to an instance of an object.'" exception on the line var myPin = new Pin(selectMapControl)...
If my lat and lng are both set to 0 then it works
Here is the stack trace in the exception:
at Mapsui.UI.Forms.Pin.OnPropertyChanged (System.String propertyName) [0x001df] in <5cc65edf513349cdba641e049bbf0143>:0
at Xamarin.Forms.BindableObject.SetValueActual (Xamarin.Forms.BindableProperty property, Xamarin.Forms.BindableObject+BindablePropertyContext context, System.Object value, System.Boolean currentlyApplying, Xamarin.Forms.Internals.SetValueFlags attributes, System.Boolean silent) [0x00114] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:510
at Xamarin.Forms.BindableObject.SetValueCore (Xamarin.Forms.BindableProperty property, System.Object value, Xamarin.Forms.Internals.SetValueFlags attributes, Xamarin.Forms.BindableObject+SetValuePrivateFlags privateAttributes) [0x00173] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:446
at Xamarin.Forms.BindableObject.SetValue (Xamarin.Forms.BindableProperty property, System.Object value, System.Boolean fromStyle, System.Boolean checkAccess) [0x0004d] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:374
at Xamarin.Forms.BindableObject.SetValue (Xamarin.Forms.BindableProperty property, System.Object value) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:349
at Mapsui.UI.Forms.Pin.set_Position (Mapsui.UI.Forms.Position value) [0x00000] in <5cc65edf513349cdba641e049bbf0143>:0
at eLunaApp.Views.RestaurantMapPage.OnAppearing () [0x0008d] in C:\x\elunaapp\eLunaApp\PageRestaurantMap\RestaurantMapPage.xaml.cs:82
at Xamarin.Forms.Page.SendAppearing () [0x00045] in D:\a\1\s\Xamarin.Forms.Core\Page.cs:452
at Xamarin.Forms.ShellContent.SendPageAppearing (Xamarin.Forms.Page page) [0x0003b] in D:\a\1\s\Xamarin.Forms.Core\Shell\ShellContent.cs:127
at Xamarin.Forms.ShellContent.SendAppearing () [0x00019] in D:\a\1\s\Xamarin.Forms.Core\Shell\ShellContent.cs:108
at Xamarin.Forms.ShellContent.OnChildAdded (Xamarin.Forms.Element child) [0x00021] in D:\a\1\s\Xamarin.Forms.Core\Shell\ShellContent.cs:138
at Xamarin.Forms.ShellContent.set_ContentCache (Xamarin.Forms.Page value) [0x0003b] in D:\a\1\s\Xamarin.Forms.Core\Shell\ShellContent.cs:182
at Xamarin.Forms.ShellContent.Xamarin.Forms.IShellContentController.GetOrCreateContent () [0x0003c] in D:\a\1\s\Xamarin.Forms.Core\Shell\ShellContent.cs:68
at Xamarin.Forms.Platform.Android.ShellSectionRenderer.OnCreateView (Android.Views.LayoutInflater inflater, Android.Views.ViewGroup container, Android.OS.Bundle savedInstanceState) [0x000f2] in D:\a\1\s\Xamarin.Forms.Platform.Android\Renderers\ShellSectionRenderer.cs:166
at AndroidX.Fragment.App.Fragment.n_OnCreateView_Landroid_view_LayoutInflater_Landroid_view_ViewGroup_Landroid_os_Bundle_ (System.IntPtr jnienv, System.IntPtr native__this, System.IntPtr native_inflater, System.IntPtr native_container, System.IntPtr native_savedInstanceState) [0x00021] in D:\a\1\s\generated\androidx.fragment.fragment\obj\Release\monoandroid90\generated\src\AndroidX.Fragment.App.Fragment.cs:1950
at (wrapper dynamic-method) Android.Runtime.DynamicMethodNameCounter.50(intptr,intptr,intptr,intptr,intptr)
Related
I'm using a custom renderer on a WebView in my project, and I need it to be able to open popups, then I added JavaScriptCanOpenWindowsAutomatically settings to the constructor, but if I set it to true the app crashes at launch, here is my renderer:
[assembly: ExportRenderer(typeof(Xamarin.Forms.WebView), typeof(HybridWebViewRenderer))]
namespace ClotureSiadForms.Droid.Renderer
{
internal class HybridWebViewRenderer : WebViewRenderer
{
public HybridWebViewRenderer(Context context) : base(context)
{
}
protected override void OnElementChanged(ElementChangedEventArgs<Xamarin.Forms.WebView> e)
{
base.OnElementChanged(e);
if (Control != null)
{
Control.Settings.JavaScriptEnabled = true;
Control.Settings.DomStorageEnabled = true;
Control.Settings.SavePassword = true;
//Control.Settings.JavaScriptCanOpenWindowsAutomatically = true;
}
}
}
}
And the error:
10-19 19:05:55.667 HUAWEI RNE-L21 Error 24197 mono-rt [ERROR] FATAL UNHANDLED EXCEPTION: System.TypeInitializationException: The type initializer for 'Types' threw an exception. ---> System.EntryPointNotFoundException: java_interop_jvm_list assembly:<unknown assembly> type:<unknown type> member:(null)
at (wrapper managed-to-native) Java.Interop.NativeMethods.java_interop_jvm_list(intptr[],int,int&)
at Java.Interop.JniRuntime.GetCreatedJavaVMs (System.IntPtr[] handles, System.Int32 bufLen, System.Int32& nVMs) [0x00000] in <d12ba608ed5a4079a11cd8a7188dddcf>:0
at Java.Interop.JniRuntime.GetAvailableInvocationPointers () [0x00000] in <d12ba608ed5a4079a11cd8a7188dddcf>:0
at Java.Interop.JniRuntime.get_CurrentRuntime () [0x00095] in <d12ba608ed5a4079a11cd8a7188dddcf>:0
at Java.Interop.JniEnvironmentInfo..ctor () [0x00006] in <d12ba608ed5a4079a11cd8a7188dddcf>:0
at Java.Interop.JniEnvironment+<>c.<.cctor>b__35_0 () [0x00000] in <d12ba608ed5a4079a11cd8a7188dddcf>:0
at System.Threading.ThreadLocal`1[T].GetValueSlow () [0x00031] in <a790ddc2dda1484d9a4b87dd85c6ca47>:0
at System.Threading.ThreadLocal`1[T].get_Value () [0x0003e] in <a790ddc2dda1484d9a4b87dd85c6ca47>:0
at Java.Interop.JniEnvironment+Types.TryFindClass (System.String classname, System.Boolean throwOnError) [0x00014] in <d12ba608ed5a4079a11cd8a7188dddcf>:0
at Java.Interop.JniEnvironment+Types.FindClass (System.String classname) [0x00000] in <d12ba608ed5a4079a11cd8a7188dddcf>:0
at Java.Interop.JniType..ctor (System.String classname) [0x00006] in <d12ba608ed5a4079a11cd8a7188dddcf>:0
at Java.Interop.JniEnvironment+Types..cctor () [0x000d2] in <d12ba608ed5a4079a11cd8a7188dddcf>:0
--- End of inner exception stack trace ---
at Android.Runtime.JNIEnv.IsInstanceOf (System.IntPtr obj, System.IntPtr clazz) [0x0000e] in <ac4226d0aad24df781f4097e7b8b972f>:0
at Android.Runtime.JNIEnv.IsGCUserPeer (System.IntPtr value) [0x0000f] in <ac4226d0aad24df781f4097e7b8b972f>:0
Then, is there another way to make blank links open in the default browser ? Or to prevent this error ?
enter image description hereThere's signature popup first time with none enter(signature stoke) close the popup by clicking on cancel button and once more reopening the popup and providing a input(stroke) once after stoke is completed variable is set to true
On onpropertychange throwing below excetion
System.ObjectDisposedException: 'Cannot access a disposed object.
Object name: 'AndroidX.AppCompat.Widget.AppCompatButton'.'
enter image description hereenter image description here
Stack Trace
at Java.Interop.JniPeerMembers.AssertSelf (Java.Interop.IJavaPeerable self) [0x00029] in :0
at Java.Interop.JniPeerMembers+JniInstanceMethods.InvokeVirtualBooleanMethod (System.String encodedMember, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue* parameters) [0x00000] in :0
at Android.Views.View.get_Enabled () [0x00000] in /Users/builder/azdo/work/1/s/xamarin-android/src/Mono.Android/obj/Release/monoandroid10/android-29/mcw/Android.Views.View.cs:6262
at XF.Material.Droid.Renderers.MaterialDrawableHelper.CreateStateListAnimator () [0x00000] in /Users/martijn/Documents/OpenSource/XF-Material-Library/XF.Material/Platforms/Android/Renderers/MaterialDrawableHelper.cs:291
at XF.Material.Droid.Renderers.MaterialDrawableHelper.UpdateElevation () [0x00008] in /Users/martijn/Documents/OpenSource/XF-Material-Library/XF.Material/Platforms/Android/Renderers/MaterialDrawableHelper.cs:286
at XF.Material.Droid.Renderers.MaterialDrawableHelper.BindableButton_PropertyChanged (System.Object sender, System.ComponentModel.PropertyChangedEventArgs e) [0x00029] in /Users/martijn/Documents/OpenSource/XF-Material-Library/XF.Material/Platforms/Android/Renderers/MaterialDrawableHelper.cs:110
at (wrapper delegate-invoke) .invoke_void_object_PropertyChangedEventArgs(object,System.ComponentModel.PropertyChangedEventArgs)
at Xamarin.Forms.BindableObject.OnPropertyChanged (System.String propertyName) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:266
at Xamarin.Forms.Element.OnPropertyChanged (System.String propertyName) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\Element.cs:362
at XF.Material.Forms.UI.MaterialButton.OnPropertyChanged (System.String propertyName) [0x0001a] in /Users/martijn/Documents/OpenSource/XF-Material-Library/XF.Material/UI/MaterialButton.cs:108
at Xamarin.Forms.BindableObject.SetValueActual (Xamarin.Forms.BindableProperty property, Xamarin.Forms.BindableObject+BindablePropertyContext context, System.Object value, System.Boolean currentlyApplying, Xamarin.Forms.Internals.SetValueFlags attributes, System.Boolean silent) [0x00114] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:510
at Xamarin.Forms.BindableObject.SetValueCore (Xamarin.Forms.BindableProperty property, System.Object value, Xamarin.Forms.Internals.SetValueFlags attributes, Xamarin.Forms.BindableObject+SetValuePrivateFlags privateAttributes) [0x00173] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:446
at Xamarin.Forms.BindingExpression.ApplyCore (System.Object sourceObject, Xamarin.Forms.BindableObject target, Xamarin.Forms.BindableProperty property, System.Boolean fromTarget) [0x00226] in D:\a\1\s\Xamarin.Forms.Core\BindingExpression.cs:160
at Xamarin.Forms.BindingExpression.Apply (System.Boolean fromTarget) [0x0003e] in D:\a\1\s\Xamarin.Forms.Core\BindingExpression.cs:56
at Xamarin.Forms.BindingExpression+BindingExpressionPart.b__49_0 () [0x00000] in D:\a\1\s\Xamarin.Forms.Core\BindingExpression.cs:762
at Xamarin.Forms.BindingExpression+BindingExpressionPart.PropertyChanged (System.Object sender, System.ComponentModel.PropertyChangedEventArgs args) [0x000cb] in D:\a\1\s\Xamarin.Forms.Core\BindingExpression.cs:773
at Xamarin.Forms.BindingExpression+WeakPropertyChangedProxy.OnPropertyChanged (System.Object sender, System.ComponentModel.PropertyChangedEventArgs e) [0x00012] in D:\a\1\s\Xamarin.Forms.Core\BindingExpression.cs:666
at (wrapper delegate-invoke) .invoke_void_object_PropertyChangedEventArgs(object,System.ComponentModel.PropertyChangedEventArgs)
at XamarinUniversity.Infrastructure.SimpleViewModel.RaisePropertyChanged (System.String propertyName) [0x00012] in :0
at ICR_MobileApp.ViewModels.SignatureSectionViewModel.OnStrokeCompleted () [0x0001c] in C:\Users\supriya.mecharla\source\repos\ICR_MobileApp\ICR_MobileApp\ICR_MobileApp\ViewModels\SectionViewModels\SignatureSectionViewModel.cs:262
at ICR_MobileApp.ViewModels.SignatureSectionViewModel.<.ctor>b__50_6 () [0x00000] in C:\Users\supriya.mecharla\source\repos\ICR_MobileApp\ICR_MobileApp\ICR_MobileApp\ViewModels\SectionViewModels\SignatureSectionViewModel.cs:168
at Xamarin.Forms.Command+<>c__DisplayClass4_0.<.ctor>b__0 (System.Object o) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\Command.cs:74
at Xamarin.Forms.Command.Execute (System.Object parameter) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\Command.cs:112
at SignaturePad.Forms.SignaturePadCanvasView.OnStrokeCompleted () [0x00039] in :0
at SignaturePad.Forms.SignaturePadCanvasRenderer.OnStrokeCompleted (System.Object sender, System.EventArgs e) [0x0000a] in :0
at Xamarin.Controls.SignaturePadCanvasView.OnStrokeCompleted (System.Object sender, System.EventArgs e) [0x0000a] in <0c0873655a504a1796935fa2cfa62e06>:0
at Xamarin.Controls.InkPresenter.OnStrokeCompleted () [0x0000a] in <0c0873655a504a1796935fa2cfa62e06>:0
at Xamarin.Controls.InkPresenter.TouchesEnded (Android.Views.MotionEvent e) [0x0003c] in <0c0873655a504a1796935fa2cfa62e06>:0
at Xamarin.Controls.InkPresenter.OnTouchEvent (Android.Views.MotionEvent e) [0x0002e] in <0c0873655a504a1796935fa2cfa62e06>:0
at Android.Views.View.n_OnTouchEvent_Landroid_view_MotionEvent (System.IntPtr jnienv, System.IntPtr native__this, System.IntPtr native_e) [0x00010] in /Users/builder/azdo/_work/1/s/xamarin-android/src/Mono.Android/obj/Release/monoandroid10/android-29/mcw/Android.Views.View.cs:18286
at (wrapper dynamic-method) Android.Runtime.DynamicMethodNameCounter.35(intptr,intptr,intptr)
While using sfprogressbar we are getting an Appcenter Error.
ProgressBarBase.ApplyDrawableColor (Android.Graphics.Drawables.Drawable drawable, Android.Graphics.Color color, Android.Graphics.PorterDuff+Mode mode)
System.ObjectDisposedException: Cannot access a disposed object. Object name: 'Android.Graphics.Drawables.ScaleDrawable .
Why this error occurred and how to resolve this error.
Java.Interop
JniPeerMembers.AssertSelf (Java.Interop.IJavaPeerable self)
Java.Interop
JniPeerMembers+JniInstanceMethods.InvokeVirtualVoidMethod (System.String encodedMember, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue* parameters)
Android.Graphics.Drawables
Drawable.SetTint (System.Int32 tintColor)
Syncfusion.Android.ProgressBar
ProgressBarBase.ApplyDrawableColor (Android.Graphics.Drawables.Drawable drawable, Android.Graphics.Color color, Android.Graphics.PorterDuff+Mode mode)
Syncfusion.Android.ProgressBar
SfLinearProgressBar.SetProgressColor ()
Syncfusion.Android.ProgressBar
ProgressBarBase.set_ProgressColor (Android.Graphics.Color value)
Syncfusion.XForms.Android.ProgressBar
ProgressBarUtility.OnLinearBarPropertyChanged (Syncfusion.Android.ProgressBar.SfLinearProgressBar native, Syncfusion.XForms.ProgressBar.SfLinearProgressBar control, System.String propertyName)
Syncfusion.Android.ProgressBar
SfLinearProgressBar.OnLinearProgressBarPropertiesChanged (System.Object sender, System.ComponentModel.PropertyChangedEventArgs e)
(wrapper delegate-invoke) <Module>.invoke_void_object_PropertyChangedEventArgs(object,System.ComponentModel.PropertyChangedEventArgs)
Xamarin.Forms
BindableObject.OnPropertyChanged (System.String propertyName)
Xamarin.Forms
Element.OnPropertyChanged (System.String propertyName)
Xamarin.Forms
BindableObject.SetValueActual (Xamarin.Forms.BindableProperty property, Xamarin.Forms.BindableObject+BindablePropertyContext context, System.Object value, System.Boolean currentlyApplying, Xamarin.Forms.Internals.SetValueFlags attributes, System.Boolean silent)
Xamarin.Forms
BindableObject.SetValueCore (Xamarin.Forms.BindableProperty property, System.Object value, Xamarin.Forms.Internals.SetValueFlags attributes, Xamarin.Forms.BindableObject+SetValuePrivateFlags privateAttributes)
Xamarin.Forms
BindingExpression.ApplyCore (System.Object sourceObject, Xamarin.Forms.BindableObject target, Xamarin.Forms.BindableProperty property, System.Boolean fromTarget)
Xamarin.Forms
BindingExpression.Apply (System.Boolean fromTarget)
Xamarin.Forms
BindingExpression+BindingExpressionPart.<PropertyChanged>b__49_0 ()
Xamarin.Forms
BindingExpression+BindingExpressionPart.PropertyChanged (System.Object sender, System.ComponentModel.PropertyChangedEventArgs args)
Xamarin.Forms
BindingExpression+WeakPropertyChangedProxy.OnPropertyChanged (System.Object sender, System.ComponentModel.PropertyChangedEventArgs e)
(wrapper delegate-invoke) <Module>.invoke_void_object_PropertyChangedEventArgs(object,System.ComponentModel.PropertyChangedEventArgs)
I just updated my MAC system and all packages in my Xamarin Project, now the App always crashes due to the following exception:
Object reference not set to an instance of an object
at XamForms.Controls.iOS.CalendarButtonRenderer.OnElementPropertyChanged (System.Object sender, System.ComponentModel.PropertyChangedEventArgs e) [0x0004a] in :0
at (wrapper delegate-invoke) .invoke_void_object_PropertyChangedEventArgs(object,System.ComponentModel.PropertyChangedEventArgs)
at Xamarin.Forms.BindableObject.OnPropertyChanged (System.String propertyName) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:229
at Xamarin.Forms.Element.OnPropertyChanged (System.String propertyName) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\Element.cs:350
at Xamarin.Forms.BindableObject.ClearValue (Xamarin.Forms.BindableProperty property, System.Boolean fromStyle, System.Boolean checkAccess) [0x000c6] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:96
at Xamarin.Forms.BindableObject.ClearValue (Xamarin.Forms.BindableProperty property) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:48
at Xamarin.Forms.Platform.iOS.VisualElementRenderer1[TElement].Dispose (System.Boolean disposing) [0x0007d] in <db18f72e3204406988680543da513ace>:0
at Xamarin.Forms.Platform.iOS.ViewRenderer2[TView,TNativeView].Dispose (System.Boolean disposing) [0x0005c] in :0
at Xamarin.Forms.Platform.iOS.ButtonRenderer.Dispose (System.Boolean disposing) [0x00064] in D:\a\1\s\Xamarin.Forms.Platform.iOS\Renderers\ButtonRenderer.cs:66
at Foundation.NSObject.Dispose () [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/13.4.0.2/src/Xamarin.iOS/Foundation/NSObject2.cs:147
at Xamarin.Forms.Platform.iOS.VisualElementPackager.Dispose (System.Boolean disposing) [0x0003f] in D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementPackager.cs:71
at Xamarin.Forms.Platform.iOS.VisualElementPackager.Dispose () [0x00000] in D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementPackager.cs:39
at Xamarin.Forms.Platform.iOS.VisualElementRenderer1[TElement].Dispose (System.Boolean disposing) [0x00058] in <db18f72e3204406988680543da513ace>:0
at Foundation.NSObject.Dispose () [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/13.4.0.2/src/Xamarin.iOS/Foundation/NSObject2.cs:147
at Xamarin.Forms.Platform.iOS.VisualElementPackager.Dispose (System.Boolean disposing) [0x0003f] in D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementPackager.cs:71
at Xamarin.Forms.Platform.iOS.VisualElementPackager.Dispose () [0x00000] in D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementPackager.cs:39
at Xamarin.Forms.Platform.iOS.VisualElementRenderer1[TElement].Dispose (System.Boolean disposing) [0x00058] in :0
at Foundation.NSObject.Dispose () [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/13.4.0.2/src/Xamarin.iOS/Foundation/NSObject2.cs:147
at Xamarin.Forms.Platform.iOS.VisualElementPackager.OnChildRemoved (Xamarin.Forms.VisualElement view) [0x0003e] in D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementPackager.cs:124
at Xamarin.Forms.Platform.iOS.VisualElementPackager.OnChildRemoved (System.Object sender, Xamarin.Forms.ElementEventArgs e) [0x0000f] in D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementPackager.cs:161
at Xamarin.Forms.Element.OnChildRemoved (Xamarin.Forms.Element child) [0x00007] in D:\a\1\s\Xamarin.Forms.Core\Element.cs:334
at Xamarin.Forms.VisualElement.OnChildRemoved (Xamarin.Forms.Element child) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:750
at Xamarin.Forms.TemplatedView.OnChildRemoved (Xamarin.Forms.Element child) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\TemplatedView.cs:92
at Xamarin.Forms.Layout.OnInternalRemoved (Xamarin.Forms.View view) [0x00012] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:473
at Xamarin.Forms.Layout.InternalChildrenOnCollectionChanged (System.Object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) [0x0002b] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:436
at System.Collections.ObjectModel.ObservableCollection1[T].OnCollectionChanged (System.Collections.Specialized.NotifyCollectionChangedEventArgs e) [0x00018] in <429bba1022b24f41b20fdc67c7554c2d>:0
at System.Collections.ObjectModel.ObservableCollection1[T].OnCollectionChanged (System.Collections.Specialized.NotifyCollectionChangedAction action, System.Object item, System.Int32 index) [0x00009] in <429bba1022b24f41b20fdc67c7554c2d>:0
at System.Collections.ObjectModel.ObservableCollection1[T].RemoveItem (System.Int32 index) [0x00021] in <429bba1022b24f41b20fdc67c7554c2d>:0
at System.Collections.ObjectModel.Collection1[T].RemoveAt (System.Int32 index) [0x00027] in :0
at Xamarin.Forms.TemplateUtilities.OnContentChanged (Xamarin.Forms.BindableObject bindable, System.Object oldValue, System.Object newValue) [0x00018] in D:\a\1\s\Xamarin.Forms.Core\TemplateUtilities.cs:63
at Xamarin.Forms.BindableObject.SetValueActual (Xamarin.Forms.BindableProperty property, Xamarin.Forms.BindableObject+BindablePropertyContext context, System.Object value, System.Boolean currentlyApplying, Xamarin.Forms.Internals.SetValueFlags attributes, System.Boolean silent) [0x00120] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:463
at Xamarin.Forms.BindableObject.SetValueCore (Xamarin.Forms.BindableProperty property, System.Object value, Xamarin.Forms.Internals.SetValueFlags attributes, Xamarin.Forms.BindableObject+SetValuePrivateFlags privateAttributes) [0x00173] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:397
at Xamarin.Forms.BindableObject.SetValue (Xamarin.Forms.BindableProperty property, System.Object value, System.Boolean fromStyle, System.Boolean checkAccess) [0x00042] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:334
at Xamarin.Forms.BindableObject.SetValue (Xamarin.Forms.BindableProperty property, System.Object value) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:311
at Xamarin.Forms.ContentView.set_Content (Xamarin.Forms.View value) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\ContentView.cs:11
at XamForms.Controls.Calendar+<>c__DisplayClass89_0.b__0 () [0x00027] in <78f786ab622940c1b06f4cfd4c30dce1>:0
at Foundation.NSAsyncActionDispatcher.Apply () [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/13.4.0.2/src/Xamarin.iOS/Foundation/NSAction.cs:152
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/13.4.0.2/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/13.4.0.2/src/Xamarin.iOS/UIKit/UIApplication.cs:65
at myproject.iOS.Application.Main (System.String[] args) [0x00001] in /Users/lin/Projects/myProject/iOS/Main.cs:12
I use below code to access SAP Odata WebService:
string strUrl = "https://...../HandlingUnitSet?$format=json";
var credentials = new NetworkCredential("user", "usr123");
var handler = new HttpClientHandler { Credentials = credentials };
var client = new System.Net.Http.HttpClient(handler);
client.DefaultRequestHeaders.Accept.Clear();
client.DefaultRequestHeaders.Add("Accept", "application/json");
var response = await client.GetAsync(strUrl);
string status = response.StatusCode.ToString();
string header = response.Headers.ToString();
string cont = response.Content.ToString();
string contactsJson = response.Content.ReadAsStringAsync().Result;
UoUnit ObjUnitList = new UoUnit();
ObjUnitList = JsonConvert.DeserializeObject<UoUnit>(contactsJson);
The Problem : I got the below error message
The url suppose to return Json Data but I did not get it. This error encountered at the line of DeserializeObject
Unexpected character encountered while parsing value: <. Path '', line 0, position 0.
at Newtonsoft.Json.JsonTextReader.ParseValue ()
{Newtonsoft.Json.JsonReaderException: Unexpected character encountered while parsing value: <. Path '', line 0, position 0.
at Newtonsoft.Json.JsonTextReader.ParseValue () [0x002b3] in <d32db49e5e3440729da31845c03ddc3a>:0
at Newtonsoft.Json.JsonTextReader.Read () [0x0004c] in <d32db49e5e3440729da31845c03ddc3a>:0
at Newtonsoft.Json.JsonReader.ReadAndMoveToContent () [0x00000] in <d32db49e5e3440729da31845c03ddc3a>:0
at Newtonsoft.Json.JsonReader.ReadForType (Newtonsoft.Json.Serialization.JsonContract contract, System.Boolean hasConverter) [0x0004a] in <d32db49e5e3440729da31845c03ddc3a>:0
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize (Newtonsoft.Json.JsonReader reader, System.Type objectType, System.Boolean checkAdditionalContent) [0x000db] in <d32db49e5e3440729da31845c03ddc3a>:0
at Newtonsoft.Json.JsonSerializer.DeserializeInternal (Newtonsoft.Json.JsonReader reader, System.Type objectType) [0x00054] in <d32db49e5e3440729da31845c03ddc3a>:0
at Newtonsoft.Json.JsonSerializer.Deserialize (Newtonsoft.Json.JsonReader reader, System.Type objectType) [0x00000] in <d32db49e5e3440729da31845c03ddc3a>:0
at Newtonsoft.Json.JsonConvert.DeserializeObject (System.String value, System.Type type, Newtonsoft.Json.JsonSerializerSettings settings) [0x0002d] in <d32db49e5e3440729da31845c03ddc3a>:0
at Newtonsoft.Json.JsonConvert.DeserializeObject[T] (System.String value, Newtonsoft.Json.JsonSerializerSettings settings) [0x00000] in <d32db49e5e3440729da31845c03ddc3a>:0
at Newtonsoft.Json.JsonConvert.DeserializeObject[T] (System.String value) [0x00000] in <d32db49e5e3440729da31845c03ddc3a>:0
}