I'm new in Xamarin. I want to add a side menu, so I took this code on GitHub and implement in my project.
I have this AccountsView page:
public partial class AccountsView : ContentPage
{
public AccountsView()
{
InitializeComponent();
GetAccountsAsync();
}
private async void GetAccountsAsync()
{
var accounts = await SQLHelper.Connection.Table<Account>().ToListAsync();
lvwAccounts.ItemsSource = accounts;
}
async void Handle_Clicked(object sender, System.EventArgs e)
{
var account = (Account)((Button)sender).BindingContext;
await Navigation.PushAsync(new AccountDetailsView(account.Id));
}
}
When i click on the menu to go this page i get an exception "object reference not set to an instance of an object" and the inner exception:
" at project.Views.AccountsView+d__2.MoveNext () [0x0000f] in /Users/user/Projects/project/project/Views/AccountsView.xaml.cs:24 \n--- End of stack trace from previous location where exception was thrown ---\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.9.1.24/src/Xamarin.iOS/mcs/class/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:152 \n at System.Runtime.CompilerServices.AsyncMethodBuilderCore+<>c.b__6_0 (System.Object state) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.9.1.24/src/Xamarin.iOS/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/AsyncMethodBuilder.cs:1018 \n at UIKit.UIKitSynchronizationContext+c__AnonStorey0.<>m__0 () [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.9.1.24/src/Xamarin.iOS/UIKit/UIKitSynchronizationContext.cs:24 \n at Foundation.NSAsyncActionDispatcher.Apply () [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.9.1.24/src/Xamarin.iOS/Foundation/NSAction.cs:163 \n--- End of stack trace from previous location where exception was thrown ---\n at (wrapper managed-to-native) UIKit.UIApplication.UIApplicationMain(int,string[],intptr,intptr)\n at UIKit.UIApplication.Main (System.String[] args, System.IntPtr principal, System.IntPtr delegate) [0x00005] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.9.1.24/src/Xamarin.iOS/UIKit/UIApplication.cs:79 \n at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x00038] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.9.1.24/src/Xamarin.iOS/UIKit/UIApplication.cs:63 \n at project.iOS.Application.Main (System.String[] args) [0x00001] in /Users/user/Projects/project/iOS/Main.cs:17 "
If I remove the GetAccountsAsync() method and it calls from ctor all works fine but with no data.
Something with the async call to DB cause the problem.
If I don't implement side menu and master page my code works fine.
Can someone help me with this?
Related
[Xamarin.Forms.GoogleMaps][1] is failing when deploying to IOS (in my case iPhone phisical device).
The app is trying to start but then crashes to the OS. Visual Studio does not catch the break point.
In the output window I get this:
Loaded assembly:
/private/var/mobile/Containers/Data/Application/BE8F87C7-8FB5-4F76-9674-03D160780B77/Documents/XFGoogleMapSampleiOS.content/Xamarin.Forms.Xaml.dll
[External] Loaded assembly:
/private/var/containers/Bundle/Application/F4979BA1-4F02-476D-BB93-7A84EE654A10/XFGoogleMapSampleiOS.app/System.Xml.dll
[External] Thread started: #4 Thread started: #5 Thread started: #6 Thread started: #7 Resolved pending breakpoint at 'BasicMapPage.xaml.cs:139,1'
to void XFGoogleMapSample.BasicMapPage.<.ctor>b__0_15 (object sender,
Xamarin.Forms.GoogleMaps.CameraChangedEventArgs args) [0x00008].
Loaded assembly:
/private/var/containers/Bundle/Application/F4979BA1-4F02-476D-BB93-7A84EE654A10/XFGoogleMapSampleiOS.app/System.Net.Http.dll
[External] Loaded assembly:
/private/var/containers/Bundle/Application/F4979BA1-4F02-476D-BB93-7A84EE654A10/XFGoogleMapSampleiOS.app/System.Drawing.Common.dll
[External] [0:] An error occurred: 'Object reference not set to an
instance of an object.'. Callstack: ' at
Xamarin.Forms.GoogleMaps.iOS.MapRenderer.UpdateIsShowingUser
(System.Nullable1[T] initialMyLocationButtonEnabled) <0x119727660 + 0x0007a> in <cae073484d4d4db5b36708f421f24080>:0 at Xamarin.Forms.GoogleMaps.iOS.MapRenderer.OnElementChanged (Xamarin.Forms.Platform.iOS.ElementChangedEventArgs1[TElement] e)
<0x118649e28 + 0x002d0> in :0 at
Xamarin.Forms.Platform.iOS.VisualElementRenderer1[TElement].SetElement (TElement element) [0x00134] in D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementRenderer.cs:193 at Xamarin.Forms.Platform.iOS.VisualElementRenderer1[TElement].Xamarin.Forms.Platform.iOS.IVisualElementRenderer.SetElement
(Xamarin.Forms.VisualElement element) [0x00000] in
D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementRenderer.cs:141 at
Xamarin.Forms.Platform.iOS.Platform.CreateRenderer
(Xamarin.Forms.VisualElement element) [0x00014] in
D:\a\1\s\Xamarin.Forms.Platform.iOS\Platform.cs:199 at
Xamarin.Forms.Platform.iOS.VisualElementPackager.OnChildAdded
(Xamarin.Forms.VisualElement view) [0x0004f] in
D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementPackager.cs:79 at
Xamarin.Forms.Platform.iOS.VisualElementPackager.Load () [0x0001e] in
D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementPackager.cs:46 at
Xamarin.Forms.Platform.iOS.VisualElementRenderer1[TElement].SetElement (TElement element) [0x000f0] in D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementRenderer.cs:180 at Xamarin.Forms.Platform.iOS.VisualElementRenderer1[TElement].Xamarin.Forms.Platform.iOS.IVisualElementRenderer.SetElement
(Xamarin.Forms.VisualElement element) [0x00000] in
D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementRenderer.cs:141 at
Xamarin.Forms.Platform.iOS.Platform.CreateRenderer
(Xamarin.Forms.VisualElement element) [0x00014] in
D:\a\1\s\Xamarin.Forms.Platform.iOS\Platform.cs:199 at
Xamarin.Forms.Platform.iOS.VisualElementPackager.OnChildAdded
(Xamarin.Forms.VisualElement view) [0x0004f] in
D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementPackager.cs:79 at
Xamarin.Forms.Platform.iOS.VisualElementPackager.Load () [0x0001e] in
D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementPackager.cs:46 at
Xamarin.Forms.Platform.iOS.PageRenderer.ViewDidLoad () [0x00086] in
D:\a\1\s\Xamarin.Forms.Platform.iOS\Renderers\PageRenderer.cs:123
at (wrapper managed-to-native)
ObjCRuntime.Messaging.IntPtr_objc_msgSendSuper(intptr,intptr) at
UIKit.UIViewController.get_View () [0x0002a] in
/Library/Frameworks/Xamarin.iOS.framework/Versions/14.2.0.12/src/Xamarin.iOS/UIKit/UIViewController.g.cs:3267
at Xamarin.Forms.Platform.iOS.PageRenderer.get_NativeView () [0x00000]
in D:\a\1\s\Xamarin.Forms.Platform.iOS\Renderers\PageRenderer.cs:41
at Xamarin.Forms.Platform.iOS.PageRenderer.SetElement
(Xamarin.Forms.VisualElement element) [0x0004f] in
D:\a\1\s\Xamarin.Forms.Platform.iOS\Renderers\PageRenderer.cs:56 at
Xamarin.Forms.Platform.iOS.Platform.CreateRenderer
(Xamarin.Forms.VisualElement element) [0x00014] in
D:\a\1\s\Xamarin.Forms.Platform.iOS\Platform.cs:199 at
Xamarin.Forms.Platform.iOS.NavigationRenderer.CreateViewControllerForPage
(Xamarin.Forms.Page page) [0x00008] in
D:\a\1\s\Xamarin.Forms.Platform.iOS\Renderers\NavigationRenderer.cs:357
at Xamarin.Forms.Platform.iOS.NavigationRenderer.OnPushAsync
(Xamarin.Forms.Page page, System.Boolean animated) [0x0001d] in
D:\a\1\s\Xamarin.Forms.Platform.iOS\Renderers\NavigationRenderer.cs:344
at Xamarin.Forms.Platform.iOS.NavigationRenderer.b__42_0
(Xamarin.Forms.Page p) [0x00024] in
D:\a\1\s\Xamarin.Forms.Platform.iOS\Renderers\NavigationRenderer.cs:228
at
System.Runtime.CompilerServices.AsyncMethodBuilderCore+<>c.b__7_0
(System.Object state) [0x00000] in
/Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/AsyncMethodBuilder.cs:1021
at (wrapper delegate-invoke) .invoke_void_object(object) at
Foundation.NSAsyncSynchronizationContextDispatcher.Apply () [0x00000]
in
/Library/Frameworks/Xamarin.iOS.framework/Versions/14.2.0.12/src/Xamarin.iOS/Foundation/NSAction.cs:178
--- End of stack trace from previous location where exception was thrown ---
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/14.2.0.12/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/14.2.0.12/src/Xamarin.iOS/UIKit/UIApplication.cs:65
at XFGoogleMapSample.iOS.Application.Main (System.String[] args)
[0x00001] in
C:\Projects\Xamarin.Forms.GoogleMaps-master\XFGoogleMapSample\iOS\Main.cs:17
at (wrapper managed-to-native)
System.Reflection.RuntimeMethodInfo.InternalInvoke(System.Reflection.RuntimeMethodInfo,object,object[],System.Exception&)
at System.Reflection.RuntimeMethodInfo.Invoke (System.Object obj,
System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder
binder, System.Object[] parameters, System.Globalization.CultureInfo
culture) [0x0006a] in
/Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/mcs/class/corlib/System.Reflection/RuntimeMethodInfo.cs:395
' The app has been terminated.
First, I tried on my local project. After, I decided to get the source code of the googlemaps libray from git hub and debug it.
It breaks in the MapRenderer.cs
private void UpdateIsShowingUser(bool? initialMyLocationButtonEnabled = null)
{
#pragma warning disable 618
((MapView)Control).MyLocationEnabled = ((Map)Element).IsShowingUser;
((MapView)Control).Settings.MyLocationButton = initialMyLocationButtonEnabled ?? ((Map)Element).IsShowingUser;
#pragma warning restore 618
}
Apparently the native Google.Maps.MapView.Settings is null here. I am not sure what exacly am I doing wrong, but the same library works perfect in Andoid version. It only fails in IOS.
I have set up API keys and API on google developer console.
Visual Studio Version 16.7.7
IOS 14.1
Xamarin.iOS 14.2.0.12
I also tried the standard xamarin google maps lirary and it works fine (it just miss many features comparing to Xamarin.Forms.GoogleMaps)
[1]: https://github.com/amay077/Xamarin.Forms.GoogleMaps
I have a simple OWIN self-hosted application with a controller extending ApiController. The problem is, when I send a POST request with no data to the controller (the method doesn't have parameters), it returns:
Length Required
And then the application crashes with an unhandled ObjectDisposedException (full stack trace below). If the POST request contains data then all is well.
I removed all controller logic from the equation by replicating with this simple method:
[HttpPost]
public void MyMethod()
{
return;
}
Therefore I'm guessing it's something to do with routing? But my routes are only set up as the default:
config.Routes.MapHttpRoute("My Service", "{controller}/{action}/{id}", new { id = RouteParameter.Optional });
Why would my application be behaving in this manner?
To send the requests I use curl:
curl --request POST http://localhost/mycontroller/mymethod
Stack trace:
Unhandled Exception: System.ObjectDisposedException: Cannot access a
disposed object. Object name: 'System.Net.HttpListenerResponse'. at
System.Net.HttpListenerResponse.set_StatusCode (System.Int32 value)
[0x00016] in <59be416de143456b88b9988284f43350>:0 at
Microsoft.Owin.Host.HttpListener.RequestProcessing.OwinHttpListenerResponse.End
() [0x0001c] in <5086711574984403b242554b11c41440>:0 at
Microsoft.Owin.Host.HttpListener.RequestProcessing.OwinHttpListenerContext.End
() [0x00010] in <5086711574984403b242554b11c41440>:0 at
Microsoft.Owin.Host.HttpListener.RequestProcessing.OwinHttpListenerContext.End
(System.Exception ex) [0x0001e] in
<5086711574984403b242554b11c41440>:0 at
Microsoft.Owin.Host.HttpListener.OwinHttpListener+d__5.MoveNext
() [0x001f9] in <5086711574984403b242554b11c41440>:0
--- End of stack trace from previous location where exception was thrown --- at
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw ()
[0x0000c] in :0 at
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess
(System.Threading.Tasks.Task task) [0x0004e] in
:0 at
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification
(System.Threading.Tasks.Task task) [0x0002e] in
:0 at
System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd
(System.Threading.Tasks.Task task) [0x0000b] in
:0 at
System.Runtime.CompilerServices.TaskAwaiter.GetResult () [0x00000] in
:0 at
Microsoft.Owin.Host.HttpListener.OwinHttpListener+d__0.MoveNext
() [0x00202] in <5086711574984403b242554b11c41440>:0
--- End of stack trace from previous location where exception was thrown --- at
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw ()
[0x0000c] in :0 at
System.Runtime.CompilerServices.AsyncMethodBuilderCore.m__1
(System.Object state) [0x00000] in
:0 at
System.Threading.QueueUserWorkItemCallback.WaitCallback_Context
(System.Object state) [0x0000e] in
:0 at
System.Threading.ExecutionContext.RunInternal
(System.Threading.ExecutionContext executionContext,
System.Threading.ContextCallback callback, System.Object state,
System.Boolean preserveSyncCtx) [0x0008d] in
:0 at
System.Threading.ExecutionContext.Run
(System.Threading.ExecutionContext executionContext,
System.Threading.ContextCallback callback, System.Object state,
System.Boolean preserveSyncCtx) [0x00000] in
:0 at
System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem
() [0x0002a] in :0 at
System.Threading.ThreadPoolWorkQueue.Dispatch () [0x00096] in
:0 at
System.Threading._ThreadPoolWaitCallback.PerformWaitCallback ()
[0x00000] in :0
Maybe if you show all your controller class I can help you a little more.
Try to make your post like this.
Make one class every get/post
for example in folder Controllers/Api/MyFunction.cs
in WebApiConfig.cs
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "API/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
);
in your "MyFunction.cs"
public class MyFunction : ApiController
{
public string Get()
{
return "hello";
}
public bool Post(string param1)
{
return 1;
}
}
I'm getting the following error when trying to set an icon on a Google Maps Map Marker:
[ERR] 26/06/2018 10:02:25 a.m. : Failed to decode image. The provided
image must be a Bitmap. [ERR] 26/06/2018 10:02:25 a.m. : at
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw ()
[0x0000c] in <0711a0626e0e4d58a44e8ca32787a4a9>:0 at
Java.Interop.JniEnvironment+InstanceMethods.CallVoidMethod
(Java.Interop.JniObjectReference instance, Java.Interop.JniMethodInfo
method, Java.Interop.JniArgumentValue* args) [0x00069] in
:0 at
Android.Runtime.JNIEnv.CallVoidMethod (System.IntPtr jobject,
System.IntPtr jmethod, Android.Runtime.JValue* parms) [0x0000e] in
<5680b8d3acca4700bde9a113c467e3e5>:0 at
Android.Runtime.JNIEnv.CallVoidMethod (System.IntPtr jobject,
System.IntPtr jmethod, Android.Runtime.JValue[] parms) [0x00017] in
<5680b8d3acca4700bde9a113c467e3e5>:0 at
Android.Gms.Maps.Model.Marker.SetIcon
(Android.Gms.Maps.Model.BitmapDescriptor icon) [0x0004b] in
<51f505f20f3f4c27854ba8f47994abdb>:0 at
AMCS.Mobile.Mapping.Android.MarkerManager.UpdateMarker
(AMCS.Mobile.Entity.Mapping.IMarker markerInfo) [0x00083] in
:0 at
AMCS.Mobile.Mapping.Android.MapHelper.UpdateMarker
(AMCS.Mobile.Entity.Mapping.IMarker markerInfo) [0x00000] in
:0 at
AMCS.Mobile.AMCSMobile.Client.Android.CollectionRouteView.b__462_0
() [0x00000] in <1d292c66dbaa42139a432bad3cbbbc7b>:0 at
Java.Lang.Thread+RunnableImplementor.Run () [0x00008] in
<5680b8d3acca4700bde9a113c467e3e5>:0 at
Java.Lang.IRunnableInvoker.n_Run (System.IntPtr jnienv, System.IntPtr
native__this) [0x00008] in <5680b8d3acca4700bde9a113c467e3e5>:0 at
(wrapper dynamic-method)
System.Object:6aee8cf7-156f-44a9-94d5-15cb0790d815 (intptr,intptr)
--- End of managed Java.Lang.RuntimeException stack trace --- com.google.maps.api.android.lib6.common.apiexception.b: Failed to
decode image. The provided image must be a Bitmap. at
com.google.maps.api.android.lib6.impl.n.a(:com.google.android.gms.dynamite_dynamitemodulesb#12685024#12.6.85
(040406-197041431):12) at
com.google.maps.api.android.lib6.impl.o.a(:com.google.android.gms.dynamite_dynamitemodulesb#12685024#12.6.85
(040406-197041431):7) at
com.google.maps.api.android.lib6.impl.cy.a(:com.google.android.gms.dynamite_dynamitemodulesb#12685024#12.6.85
(040406-197041431):186) at
com.google.android.gms.maps.model.internal.q.onTransact(:com.google.android.gms.dynamite_dynamitemodulesb#12685024#12.6.85
(040406-197041431):87) at android.os.Binder.transact(Binder.java:507)
at com.google.android.gms.maps.model.internal.l$a$a.n(Unknown Source)
at com.google.android.gms.maps.model.Marker.setIcon(Unknown Source)
at mono.java.lang.RunnableImplementor.n_run(Native Method) at
mono.java.lang.RunnableImplementor.run(RunnableImplementor.java:30)
at android.os.Handler.handleCallback(Handler.java:751) at
android.os.Handler.dispatchMessage(Handler.java:95) at
android.os.Looper.loop(Looper.java:154) at
android.app.ActivityThread.main(ActivityThread.java:6780) at
java.lang.reflect.Method.invoke(Native Method) at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1496)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1386)
I can see that it's failing in the UpdateMarker method which looks like the following:
public void UpdateMarker(IMarker markerInfo)
{
// _markerLookup is a dictionary defined earlier as:
// private Dictionary<IMarker,Android.Gms.Maps.Model.Marker> _markerLookup = new Dictionary<IMarker, Android.Gms.Maps.Model.Marker>();
// It is populated elsewhere
// Check if the dictionary contains a key for the given value
if (_markerLookup.ContainsKey(markerInfo))
{
Android.Gms.Maps.Model.Marker marker = _markerLookup[markerInfo];
marker.Position = new LatLng(markerInfo.MapCoordinate.Lat, markerInfo.MapCoordinate.Lng);
marker.Draggable = markerInfo.MarkerOptions.IsDraggable;
// Create BitmapDescriptor from Resource - Blue_Vehicle definitely exists and is a .png image
BitmapDescriptor bitmapDesc =
BitmapDescriptorFactory.FromResource(Resource.Drawable.Blue_Vehicle);
if (bitmapDesc != null)
{
marker.SetIcon(bitmapDesc);
}
}
}
The marker.SetIcon method is looking for a BitMapDescriptor which as described above is created from an image resource.
I don't understand why it's throwing an exception.
I would greatly appreciate if someone could shed some light on the issue.
I create the xamarin form project and update the content view content multiple time.
Its correctly update for android. But it not work for iOS
I have update the Contentview content when click the button like that
contentView.content = mVview;
Please find the stack trace
wrapper managed-to-native
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 /Users/builder/data/lanes/3969/7beaef43/source/xamarin-macios/src/UIKit/UIApplication.cs:79
at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName,`/lanes/3969/7beaef43/source/xamarin-macios/src/UIKi1
when i put try catch, i got this stack trace
at Xamarin.Forms.Platform.iOS.EditorRenderer.Dispose (System.Boolean disposing) [0x00003] in C:\BuildAgent2\work\ca3766cfc22354a1\Xamarin.Forms.Platform.iOS\Renderers\EditorRenderer.cs:28
at Foundation.NSObject.Dispose () [0x00000] in /Users/builder/data/lanes/3969/7beaef43/source/xamarin-macios/src/Foundation/NSObject2.cs:133
at Xamarin.Forms.Platform.iOS.ListViewRenderer.Dispose (System.Boolean disposing) [0x001c4] in C:\BuildAgent2\work\ca3766cfc22354a1\Xamarin.Forms.Platform.iOS\Renderers\ListViewRenderer.cs:153
at Foundation.NSObject.Dispose () [0x00000] in /Users/builder/data/lanes/3969/7beaef43/source/xamarin-macios/src/Foundation/NSObject2.cs:133
at Xamarin.Forms.Platform.iOS.Platform.DisposeModelAndChildrenRenderers (Xamarin.Forms.Element view) [0x00038] in C:\BuildAgent2\work\ca3766cfc22354a1\Xamarin.Forms.Platform.iOS\Platform.cs:322
at Xamarin.Forms.Platform.iOS.Platform.HandleChildRemoved (System.Object sender, Xamarin.Forms.ElementEventArgs e) [0x00007] in C:\BuildAgent2\work\ca3766cfc22354a1\Xamarin.Forms.Platform.iOS\Platform.cs:433
at Xamarin.Forms.Element.OnDescendantRemoved (Xamarin.Forms.Element child) [0x00008] in C:\BuildAgent2\work\ca3766cfc22354a1\Xamarin.Forms.Core\Element.cs:600
at Xamarin.Forms.Element.OnDescendantRemoved (Xamarin.Forms.Element child) [0x00022] in C:\BuildAgent2\work\ca3766cfc22354a1\Xamarin.Forms.Core\Element.cs:603
at Xamarin.Forms.Element.OnDescendantRemoved (Xamarin.Forms.Element child) [0x00022] in C:\BuildAgent2\work\ca3766cfc22354a1\Xamarin.Forms.Core\Element.cs:603
at Xamarin.Forms.Element.OnChildRemoved (Xamarin.Forms.Element child) [0x00021] in C:\BuildAgent2\work\ca3766cfc22354a1\Xamarin.Forms.Core\Element.cs:367
at Xamarin.Forms.VisualElement.OnChildRemoved (Xamarin.Forms.Element child) [0x00000] in C:\BuildAgent2\work\ca3766cfc22354a1\Xamarin.Forms.Core\VisualElement.cs:578
at Xamarin.Forms.Layout.OnInternalRemoved (Xamarin.Forms.View view) [0x00012] in C:\BuildAgent2\work\ca3766cfc22354a1\Xamarin.Forms.Core\Layout.cs:413
at Xamarin.Forms.Layout.InternalChildrenOnCollectionChanged (System.Object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) [0x0002f] in C:\BuildAgent2\work\ca3766cfc22354a1\Xamarin.Forms.Core\Layout.cs:377
at System.Collections.ObjectModel.ObservableCollection`1[T].OnCollectionChanged (System.Collections.Specialized.NotifyCollectionChangedEventArgs e) [0x00012] in /Users/builder/data/lanes/3969/7beaef43/source/xamarin-macios/_ios-build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class/referencesource/System/compmod/system/collections/objectmodel/observablecollection.cs:288
at System.Collections.ObjectModel.ObservableCollection`1[T].OnCollectionChanged (System.Collections.Specialized.NotifyCollectionChangedAction action, System.Object item, System.Int32 index) [0x00000] in /Users/builder/data/lanes/3969/7beaef43/source/xamarin-macios/_ios-build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class/referencesource/System/compmod/system/collections/objectmodel/observablecollection.cs:351
at System.Collections.ObjectModel.ObservableCollection`1[T].RemoveItem (System.Int32 index) [0x0002b] in /Users/builder/data/lanes/3969/7beaef43/source/xamarin-macios/_ios-build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class/referencesource/System/compmod/system/collections/objectmodel/observablecollection.cs:205
at System.Collections.ObjectModel.Collection`1[T].Remove (T item) [0x0002d] in /Users/builder/data/lanes/3969/7beaef43/source/xamarin-macios/_ios-build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class/referencesource/mscorlib/system/collections/objectmodel/collection.cs:113
at Xamarin.Forms.TemplateUtilities.OnContentChanged (Xamarin.Forms.BindableObject bindable, System.Object oldValue, System.Object newValue) [0x0001a] in C:\BuildAgent2\work\ca3766cfc22354a1\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.BindableObject+SetValueFlags attributes, System.Boolean silent) [0x00108] in C:\BuildAgent2\work\ca3766cfc22354a1\Xamarin.Forms.Core\BindableObject.cs:584
at Xamarin.Forms.BindableObject.SetValueCore (Xamarin.Forms.BindableProperty property, System.Object value, Xamarin.Forms.BindableObject+SetValueFlags attributes, Xamarin.Forms.BindableObject+SetValuePrivateFlags privateAttributes) [0x0014b] in C:\BuildAgent2\work\ca3766cfc22354a1\Xamarin.Forms.Core\BindableObject.cs:378
at Xamarin.Forms.BindableObject.SetValue (Xamarin.Forms.BindableProperty property, System.Object value, System.Boolean fromStyle, System.Boolean checkAccess) [0x0005f] in C:\BuildAgent2\work\ca3766cfc22354a1\Xamarin.Forms.Core\BindableObject.cs:531
at Xamarin.Forms.BindableObject.SetValue (Xamarin.Forms.BindableProperty property, System.Object value) [0x00000] in C:\BuildAgent2\work\ca3766cfc22354a1\Xamarin.Forms.Core\BindableObject.cs:83
at Xamarin.Forms.ContentView.set_Content (Xamarin.Forms.View value) [0x00000] in C:\BuildAgent2\work\ca3766cfc22354a1\Xamarin.Forms.Core\ContentView.cs:11
at EgnatiumFull.Pages.QuestionAnswerPage.UpdateTheQuestionLayout () [0x00144] in /Volumes/MS/prjects/Egnatium/EgnatiumFinal/EgnatiumFinal/EgnatiumFinal/Pages/QuestionAnswerPage.cs:539
at EgnatiumFull.Pages.QuestionAnswerPage+<OnAppearing>c__async1.MoveNext () [0x0007e] in /Volumes/MS/prjects/Egnatium/EgnatiumFinal/EgnatiumFinal/EgnatiumFinal/Pages/QuestionAnswerPage.cs:383
--- End of stack trace from previous location where exception was thrown ---
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 /Users/builder/data/lanes/3969/7beaef43/source/xamarin-macios/src/UIKit/UIApplication.cs:79
at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x00038] in /Users/builder/data/lanes/3969/7beaef43/source/xamarin-macios/src/UIKit/UIApplication.cs:63
at EgnatiumFinal.iOS.Application.Main (System.String[] args) [0x00008] in /Users/saifamily/Documents/14_2_17/EgnatiumFinal/EgnatiumFinal/EgnatiumFinal.iOS/Main.cs:17 xa
Finally I found the solution in my own way, i think i don't know is this correct way but in my case it work perfectly
I rendererd the list view for ios and overide the methods dispose with try/catch statement
protected override void Dispose()
{
try{
base.Dispose();
}
Catch(Exception ex)
{
return;
}
}
On Android I am getting this error Java.Lang.IllegalArgumentException:
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000b] in /Users/builder/data/lanes/2058/58099c53/source/mono/mcs/class/corlib/System.Runtime.ExceptionServices/ExceptionDispatchInfo.cs:61
at System.Runtime.CompilerServices.AsyncMethodBuilderCore.m__0 (object) [0x00000] in /Users/builder/data/lanes/2058/58099c53/source/mono/external/referencesource/mscorlib/system/runtime/compilerservices/AsyncMethodBuilder.cs:1006
at Android.App.SyncContext/c__AnonStorey0.<>m__0 () [0x00000] in /Users/builder/data/lanes/2058/58099c53/source/monodroid/src/Mono.Android/src/Android.App/SyncContext.cs:18
at Java.Lang.Thread/RunnableImplementor.Run () [0x0000b] in /Users/builder/data/lanes/2058/58099c53/source/monodroid/src/Mono.Android/src/Java.Lang/Thread.cs:36
at Java.Lang.IRunnableInvoker.n_Run (intptr,intptr) [0x00009] in /Users/builder/data/lanes/2058/58099c53/source/monodroid/src/Mono.Android/platforms/android-21/src/generated/Java.Lang.IRunnable.cs:71
at (wrapper dynamic-method) object.7dac782f-30e4-45cb-a248-e0c4c79fbcad (intptr,intptr)
--- End of managed exception stack trace --- java.lang.IllegalArgumentException at
android.media.MediaMetadataRetriever.setDataSource(MediaMetadataRetriever.java:169) at dalvik.system.NativeStart.run(Native Method)
using this code to retrive *.mp3 file duration:
public async Task<string> GetTrackDuration(string pathToFile)
{
MediaMetadataRetriever reader = new MediaMetadataRetriever();
await reader.SetDataSourceAsync (global::Android.App.Application.Context, Android.Net.Uri.Parse (pathToFile));
return reader.ExtractMetadata(MetadataKey.Duration).ToString();
}
where is the problem? I have tried all of the posible constructors