I am getting the exception ArgumentException was Unhandled(The Parameter is incorrect) in wp7 app when i touches the screen. I have already put all break points, but not getting why this exception is coming?Following i am putting the stack trace of that exception. Please help me?
at MS.Internal.XcpImports.CheckHResult(UInt32 hr)
at MS.Internal.XcpImports.UIElement_HitTestPoint(UIElement element, Point ptHit)
at System.Windows.Media.VisualTreeHelper.FindElementsInHostCoordinates(Point intersectingPoint, UIElement subtree)
at Microsoft.Phone.Controls.GestureListener.TouchStart()
at Microsoft.Phone.Controls.GestureListener.OnTouchFrameReported(Object sender, TouchFrameEventArgs e)
at System.Windows.Input.Touch.OnTouch(Object sender, TouchFrameEventArgs e)
at MS.Internal.JoltHelper.RaiseEvent(IntPtr target, UInt32 eventId, IntPtr coreEventArgs, UInt32 eventArgsTypeIndex)
This is the problem with Microshoft.Phone.Controls.Toolkit. This is a kind of bug in this library. When I removed all the code of gesture from xaml file then the above exception is not coming. I don't know what's the actual reason behind this.
Related
I'm working on my first Xamarin Forms application. I've run into an issue that I cannot figure out how to debug. There's a null value in the theme. But there aren't a lot of indicators as to what may be missing. If I catch this exception and ignore it, there doesn't seem to be any issue with the app execution.
When I change the orientation of the phone, I get this exception:
{System.ArgumentNullException: Value cannot be null.
Parameter name: enumerable
at Xamarin.Forms.Internals.EnumerableExtensions.IndexOf[T] (System.Collections.Generic.IEnumerable`1[T] enumerable, T item) [0x00003] in D:\a\1\s\Xamarin.Forms.Core\EnumerableExtensions.cs:79
at Xamarin.Forms.Application.OnRequestedThemeChanged (Xamarin.Forms.AppThemeChangedEventArgs args) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\Application.cs:172
at Xamarin.Forms.Platform.Android.FormsAppCompatActivity.OnConfigurationChanged (Android.Content.Res.Configuration newConfig) [0x0001e] in D:\a\1\s\Xamarin.Forms.Platform.Android\AppCompat\FormsAppCompatActivity.cs:90
at App1.Droid.MainActivity.OnConfigurationChanged (Android.Content.Res.Configuration newConfig) [0x00002] in C:\source\repos\App1\App1\App1.Android\MainActivity.cs:30 }
I see it comes from the internal Forms code. Any idea what it is trying to enumerate over?
The comment asks for the code at line MainActivity.cs:30
The code at line 30 is base.OnConfigurationChanged(newConfig);
The point is that the exception happens in the internal Xamarin.Forms code and I have no idea what the enumeration is supposed to represent.
public override void OnConfigurationChanged(Configuration newConfig)
{
try
{
base.OnConfigurationChanged(newConfig);
}
catch (ArgumentNullException ex)
{
string m = ex.Message;
}
}
I had the same problem and rolling Xamarin.Forms back to version 4.6.0.726 fixed it.
I have submitted a bug report on Xamarin.Forms Github https://github.com/xamarin/Xamarin.Forms/issues/10733
This link describes how to handle exceptions in iOS
Runtime.MarshalManagedException += (object sender, MarshalManagedExceptionEventArgs args) =>
{
Console.WriteLine ("Marshaling managed exception");
Console.WriteLine (" Exception: {0}", args.Exception);
Console.WriteLine (" Mode: {0}", args.ExceptionMode);
};
Runtime.MarshalObjectiveCException += (object sender, MarshalObjectiveCExceptionEventArgs args) =>
{
Console.WriteLine ("Marshaling Objective-C exception");
Console.WriteLine (" Exception: {0}", args.Exception);
Console.WriteLine (" Mode: {0}", args.ExceptionMode);
};
In addition, I've seen other Xamarin samples use this in the AppDelegate
AppDomain.CurrentDomain.UnhandledException += (sender, e) => {
try
{
var exception = ((Exception)e.ExceptionObject).GetBaseException();
Console.WriteLine("**SPORT UNHANDLED EXCEPTION**\n\n" + exception);
exception.Track();
}
catch
{
throw;
}
};
Question
What are the exception types (if more than Managed/Unmanaged), and how do I capture everything?
It goes without saying that a 'global' exception handler should not be a replacement for correctly catching expected or anticipated exceptions from blocks of code you anticipate to see issues with (perhaps because you use the parrallel libaries, or anything with any kind of thread complexity).
'global' exception handlers (in my opinion) should be used to catch anything you've failed to spot during development and testing. Personally I write these to a log file in our applications and handle them as 'Critical Exceptions' as they will cause the application to crash. My preferred method is to assign an event to 'AppDomain.CurrentDomain.UnhandledException'.
That being said during development, testing and if during production the users of your application happen to have 'diagnostic reporting' set to on you will be able to access apples exception logs. These can be useful but bear in mind they will give you the 'native' stack trace and won't have anything specific to xamarin in them. So take them with a pinch of salt.
as to your question, assigning to 'AppDomain.CurrentDomain.UnhandledException' will capture every exception that you haven't done or forseen yourself. you don't need to know the types explicitly as the stack trace will obviously tell you what they are. it's also worth noting that you can only use that event to record information or perform very basic functions as the app will close irrespective of what you do. So use it to log as much information regarding your application as possible.
It is currently impossible to stop your application from closing if it hits the unhandledexception event.
I'm working on a WP7 app where i need to delete a row using the DeleteOnSubmit() method, but i keep getting a NullReferenceException error. I can't find where the issue is.
public void HardDeleteOrder(int deleteOrderId)
{
var oResult = from o in App.orderDataContext.orders
where o.OrderId == deleteOrderId
select o;
foreach (var oRow in oResult)
{
App.orderDataContext.Orders.DeleteOnSubmit(oRow);
}
App.orderDataContext.SubmitChanges();
}
When i run this, the code crashes on the ending brace of the method with an exception message "NullReferenceException was unhandled".
Here's the Stack trace:
System.NullReferenceException was unhandled
Message=NullReferenceException
StackTrace:
at System.Data.Linq.Mapping.MetaAccessor`2.SetBoxedValue(Object& instance, Object value)
at System.Data.Linq.ChangeProcessor.ClearForeignKeysHelper(MetaAssociation assoc, Object trackedInstance)
at System.Data.Linq.ChangeProcessor.ClearForeignKeyReferences(TrackedObject to)
at System.Data.Linq.ChangeProcessor.PostProcessUpdates(List`1 insertedItems, List`1 deletedItems)
at System.Data.Linq.ChangeProcessor.SubmitChanges(ConflictMode failureMode)
at System.Data.Linq.DataContext.SubmitChanges(ConflictMode failureMode)
at System.Data.Linq.DataContext.SubmitChanges()
at orders.viewmodels.OrderViewModel.HardDeleteOrder(Int32 deleteOrderId)
at orders.OrderView.RemoveOrderFromDatabase()
at orders.OrderView.RemoveOrder()
at orders.OrderView.detailsBarCancel_Click(Object sender, EventArgs e)
at orders.App.detailsBarCancel_Click(Object sender, EventArgs e)
at Microsoft.Phone.Shell.ApplicationBarItemContainer.FireEventHandler(EventHandler handler, Object sender, EventArgs args)
at Microsoft.Phone.Shell.ApplicationBarIconButton.ClickEvent()
at Microsoft.Phone.Shell.ApplicationBarIconButtonContainer.ClickEvent()
at Microsoft.Phone.Shell.ApplicationBar.OnCommand(UInt32 idCommand)
at Microsoft.Phone.Shell.Interop.NativeCallbackInteropWrapper.OnCommand(UInt32 idCommand)
What am I missing here ?
This is mostly due to foreign key constraint.
According to
http://msdn.microsoft.com/en-us/library/bb386925.aspx
LINQ to SQL does not support or recognize cascade-delete operations. If you want to delete a row in a table that has constraints against it, you must complete either of the following tasks:
Set the ON DELETE CASCADE rule in the foreign-key constraint in the database.
Use your own code to first delete the child objects that prevent the parent object from being deleted.
This exception has been popping up for my windows phone game on my main screen when navigating to a level select screen.
As far as i can tell this can happen if there's a Dispatch timer that isn't stopped before navigating OR the page is trying to navigate to itself. I fairly certain it's not the later as there's only one path for it to go.
I don't have any specific Dispatch timers on the page, but i do have a storyboard / animation going. Could this possibly be the cause?
Dispatcher Timer:
http://mobileworld.appamundi.com/blogs/petevickers/archive/2011/03/22/windows-phone-7-no-fragment-support-right-now.aspx
Stack Trace:
Exception caught. Message: No Fragment support right now
Trace: at System.Windows.Navigation.NavigationService.Navigate(Uri source)
at AppleBin.MainPage.btnLevelSelect_Click(Object sender, RoutedEventArgs e)
at System.Windows.Controls.Primitives.ButtonBase.OnClick()
at System.Windows.Controls.Button.OnClick()
at System.Windows.Controls.Primitives.ButtonBase.OnMouseLeftButtonUp(MouseButtonEventArgs e)
at System.Windows.Controls.Control.OnMouseLeftButtonUp(Control ctrl, EventArgs e)
at MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, String eventName)
The thing is, I got a weird exception from Windows Phone app I am developing:
System.Exception was unhandled
Message=Unspecified error
StackTrace:
at MS.Internal.XcpImports.CheckHResult(UInt32 hr)
at MS.Internal.XcpImports.Collection_AddValue[T](PresentationFrameworkCollection`1 collection, CValue value)
at MS.Internal.XcpImports.Collection_AddDependencyObject[T](PresentationFrameworkCollection`1 collection, DependencyObject value)
at System.Windows.PresentationFrameworkCollection`1.AddDependencyObject(DependencyObject value)
at System.Windows.Controls.UIElementCollection.AddInternal(UIElement value)
at System.Windows.PresentationFrameworkCollection`1.Add(UIElement value)
at System.Windows.Controls.ItemsControl.AddVisualChild(Int32 index, DependencyObject container, Boolean needPrepareContainer)
at System.Windows.Controls.ItemsControl.AddContainerForPosition(GeneratorPosition position)
at System.Windows.Controls.ItemsControl.OnItemsChangedHandler(Object sender, ItemsChangedEventArgs args)
at System.Windows.Controls.ItemContainerGenerator.OnItemAdded(Object item, Int32 index)
at System.Windows.Controls.ItemContainerGenerator.System.Windows.Controls.ICollectionChangedListener.OnCollectionChanged(Object sender, NotifyCollectionChangedEventArgs args)
at System.Windows.Controls.WeakCollectionChangedListener.SourceCollectionChanged(Object sender, NotifyCollectionChangedEventArgs e)
at System.Windows.Controls.ItemCollection.NotifyCollectionChanged(NotifyCollectionChangedEventArgs e)
at System.Windows.Controls.ItemCollection.System.Windows.Controls.ICollectionChangedListener.OnCollectionChanged(Object sender, NotifyCollectionChangedEventArgs e)
at System.Windows.Controls.WeakCollectionChangedListener.SourceCollectionChanged(Object sender, NotifyCollectionChangedEventArgs e)
at System.Collections.ObjectModel.ObservableCollection`1.OnCollectionChanged(NotifyCollectionChangedEventArgs e)
at System.Collections.ObjectModel.ObservableCollection`1.InsertItem(Int32 index, FormItem item)
at System.Collections.ObjectModel.Collection`1.Add(FormItem item)
at //My Code
What my code tried to do is add a item to an ObservableCollection.
I want to step into System.Windows code so I can see what that "Unspecified error" is.
I already do the following in my Visual Studio:
Enable .NET Framework source stepping
Enable source server support
Enable Microsoft Symbol Servers
Despite that, I can't step in (double clicking) into any of System.Windows methods in the call stack.
Any help is appreciated. Let me know if any of you need more clarification.