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.
Related
We've got a Xamarin.Forms Android app in which we're displaying progress on a loading page, the progress value being sent by an event from another class.
We're using FreshMvvm which has ViewIsAppearing and ViewIsDisappearing overrides available in the PageModel.
So we're subscribing on ViewIsAppearing, and unsubscribing in ViewIsDisappearing - we're also unsubscribing in a PrepareForDispose method which is intended to ensure the PageModel has cleaned up so that it can be disposed.
Code is below. ProgressManager is supplied by IoC
protected override void ViewIsAppearing (object sender, EventArgs e)
{
base.ViewIsAppearing (sender, e);
ProgressManager.ProgressEvent += ProgressManager_ProgressEvent;
}
protected override void ViewIsDisappearing (object sender, EventArgs e)
{
base.ViewIsDisappearing (sender, e);
RemoveEventHandlers();
}
public override void PrepareForDispose()
{
RemoveEventHandlers();
base.PrepareForDispose();
}
private void RemoveEventHandlers()
{
ProgressManager.ProgressEvent -= ProgressManager_ProgressEvent;
}
The problem is that, when examining object in Profiler, we can see the LoadingPageModel is still in memory, because of the EventArgs created in the ViewIsAppearing (examining the "Paths To Root" in Profiler tells us this).
When I log/debug the app, I can see that RemoveEventHandlers has been called.
So is _ProgressManager.ProgressEvent -= ProgressManager_ProgressEvent;_ failing to remove the handler, or is there another reason that we've still got a reference to the PageModel from the EventArgs?
Edit One possibility is that we're subscribing more than once, but unsubscribing only once. I've checked with debug/logging, and I don't think this is the case. We're subscribing/unsubscribing symmetrically.
It turns out that we were subscribing twice (due to the lifecyle of the page in question at the start of the app lifecycle). Therefore the single unsubscribe was leaving a subscription behind.
Fixing this fixed the problem.
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.
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)
I'm trying to combine multiple js file references using Telerik's script manager. Here is the code I have on page load:
System.Web.UI.ScriptReference jsFile1 = new System.Web.UI.ScriptReference('/virtual_folder/jsfile1.js');
System.Web.UI.ScriptReference jsFile2 = new System.Web.UI.ScriptReference('/virtual_folder/jsfile2.js');
this.Master.ScriptManager.CompositeScript.Scripts.Add(jsFile1);
this.Master.ScriptManager.CompositeScript.Scripts.Add(jsFile2);
I'm getting an error:
[NullReferenceException: Object reference not set to an instance of an object.]
System.Collections.ObjectModel.Collection`1.Add(T item) +18
Telerik.Web.UI.RadScriptManager.Page_PreRenderComplete(Object sender, EventArgs e) +95
System.EventHandler.Invoke(Object sender, EventArgs e) +0
System.Web.UI.Page.OnPreRenderComplete(EventArgs e) +8695102
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1029
What am I doing wrong?
I think that the script combining only works for embedded resources currently so you would have to embed your js Files inside a dll.
On a side note you know you can use
this.Master.ScriptManager.
tried using
RadScriptManager.GetCurrent(this)
I am assuming you are calling this from an aspx page and not an ascx control, otherwise you have to use this.Page.