Showing posts with label bugs. Show all posts
Showing posts with label bugs. Show all posts

Sunday, August 5, 2012

Success: a 7.1 app backed up on a remote server!


I've spent a bit of time now trying to get the upgraded 7.1 version working, however the app crashes on loading the schedule pivot page containing the jumplist.  I decided to try and put a plain list of the items in order to get a functioning 7.1 app - but  found that the crash wasn't caused by the telerik controls at all.

I tried to get the minimal list going with this:
        <controls:Pivot
           
 x:Name="schedulePivot"
           
 HeaderTemplate="{StaticResource pivotTitleTemplate}">
            <controls:PivotItem>
                <ListBox
                   
 ItemsSource="{Binding events}"
                   
 ItemTemplate="{StaticResource eventTemplate}">
                </ListBox>
            </controls:PivotItem> (line 64)
        </controls:Pivot>

I got this XAML parse error: AG_E_UNKNOWN_ERROR [Line: 64 Position: 34]


        <controls:Pivot
           
 x:Name="schedulePivot"
           
 HeaderTemplate="{StaticResource pivotTitleTemplate}">
            <controls:PivotItem>
                <TextBlock Text="hello" />
            </controls:PivotItem> (line 61)
        </controls:Pivot>

Gives me the same error on line 61, so it isn't about the lists at all.

It turns out I got this error as soon as I add any PivotItem to the pivot, even an empty one.

Ok...looked into the exception stack trace and it included this detail:


            at System.Windows.UIElement.UpdateLayout()
            at Microsoft.Phone.Controls.Pivot.OnItemsChanged(NotifyCollectionChangedEventArgs e)
            at System.Windows.Controls.ItemsControl.OnItemCollectionChanged(Object sender, NotifyCollectionChangedEventArgs e)
            at System.Windows.Controls.ItemCollection.NotifyCollectionChanged(NotifyCollectionChangedEventArgs e)
            at System.Windows.Controls.ItemCollection.NotifyCollectionReady()
            at System.Windows.Controls.ItemsControl.NotifyAllItemsAdded(IntPtr nativeItemsControl)
            at MS.Internal.XcpImports.Application_LoadComponentNative(IntPtr pContext, IntPtr pComponent, UInt32 cUriStringLength, String uriString, UInt32 cXamlStrLength, Byte* pXamlStr, UInt32 cAssemblyStrLength, String assemblyStr)
            at MS.Internal.XcpImports.Application_LoadComponent(IManagedPeerBase componentAsDO, String resourceLocator, UnmanagedMemoryStream stream, UInt32 numBytesToRead, String assemblyString)
            at System.Windows.Application.LoadComponent(Object component, Uri resourceLocator)
            at PAX7.View.SchedulePivotView.InitializeComponent()
            at PAX7.View.SchedulePivotView.OnNavigatedTo(NavigationEventArgs e)
            at Microsoft.Phone.Controls.PhoneApplicationPage.InternalOnNavigatedTo(NavigationEventArgs e)

So I thought perhaps the exception was something to do with the pivotitems I was creating not working with the data I'm assigning to it? I removed the PivotItems and set DataTemplates on the Pivot itself, like this:


        <controls:Pivot x:Name="schedulePivot"
                       
 HeaderTemplate="{StaticResource pivotTitleTemplate}"
                       
 ItemTemplate="{StaticResource pivotListTemplate}">
                        
        </controls:Pivot>

Referring to existing templates like this:
        <DataTemplate x:Key="pivotListTemplate">
            <ListBox
               
 ItemsSource="{Binding events}"
               
 ItemTemplate="{StaticResource eventTemplate}">
            </ListBox>
        </DataTemplate>

Magic! Finally I have a working app built on the 7.1 SDK :) Obviously I committed it straight away. Then I remembered that I hadn't got a backup on a separate machine yet, so I googled remote repository hg nearlyfreespeech, and found this awesome page:

Before sending it up to my new remote repository,  I thought I'd make sure it wasn't including all my generated files. I found a couple relevant Stack Overflow questions  (e.g. http://stackoverflow.com/questions/3426231/mercurial-hgignore-some-questions-on-how-to-ignore-a-single-file) that led me to the help page (http://www.selenic.com/mercurial/hgignore.5.html). Although when I look at 'all files' in the repository it doesn't list the bin/obj directories now, when I ran the clone it still did because it was looking at the history of the repository, which obviously still mentioned them.

Then cloning failed anyway with an 'invalid argument' error. Google told me there was a known issue with clone/push/pull of large filesets on windows? Lame! (http://mercurial.808500.n3.nabble.com/TortoiseHG-Large-File-Commit-only-40Meg-is-size-td2140178.html) 
So I tried creating a bundle of just the latest revision (http://tortoisehg.bitbucket.org/manual/0.9/changelog.html#revision-context-menus) and cloning it, but tortoise just went ahead and tried creating a stupid huge bundle again when I hit clone, instead of pulling from the bundle. So I turned on the server option, but couldn't figure out what the url should be - when I tried hg pull <url listed in serve ui> I got an error that the hostname wasn't recognised.
I uploaded the bundle I'd created through ssh, and tried pulling from it locally (inspired by http://weblogs.java.net/blog/kohsuke/archive/2007/08/mercurial_trans.html) but got an error that the parent wasn't recognised. However import/export also didn't work, saying it couldn't find files to patch. So I created a backup bundle as listed here (http://www.southampton.ac.uk/~fangohr/computing/hg.html#use-mercurial-without-access-to-server-using-bundles) and copied that to the server, pulled from that and finally had a repository. Done!

I think the whole rigmarole indicates that I don't have a strong enough grasp on how hg is supposed to work.  Let's see how it goes when I try and just copy over a changeset...

Thursday, May 24, 2012

Upgrading to 7.1


I upgraded my app project to 7.1 back in late March, but it didn't go smoothly. 

Immediately after upgrading, I wanted to run the project and make sure upgrading hadn't broken anything. Unfortunately the first thing I got was a cryptic runtime Exception: 'WrappedException' with details 'Unspecified Error', breaking when I initialised a boolean for the first time. I googled the exception and found other people complaining that upgrading their projects gave them these errors as well - http://forums.create.msdn.com/forums/t/88547.aspx - the problem seemed to be running the old version of the Silverlight Toolkit or the CodingForFun toolkit. I have both of these, so time to upgrade them through nuget.
But...it turned out I have the most recent version? Crap. Try rebuilding from clean - didn't help. 

I searched again and found two articles both mentioning this error in relation to template bindings - http://www.wirebear.com/blog/2010/10/21/windows-phone-7-unspecified-error/ and http://www.telerik.com/community/forums/windows-phone/databound-listbox/unspecified-error-on-databoundlistbox-for-mango.aspx  so I guess I went through my project and checked the templates on that page.
  1. Commented out both the headertemplate and the jumplist itemtemplate - the app ran fine
  1. Put back in just the header template - app ran fine. So I guess it is /sigh/ somewhere within my horrible nested jumplist template.
  1. Just for fun, put them all back in - fails! The exception detail:

MS.Internal.WrappedException was unhandled
  Message=Unspecified error
  StackTrace:
       at MS.Internal.XcpImports.CheckHResult(UInt32 hr)
       at MS.Internal.XcpImports.UIElement_UpdateLayout(UIElement element)
       at System.Windows.UIElement.UpdateLayout()
.....
 InnerException:
       Message=Unspecified error
       StackTrace:
            at MS.Internal.XcpImports.CheckHResult(UInt32 hr)
            at MS.Internal.XcpImports.UIElement_Measure_WithDesiredSize(UIElement element, Size availableSize)
            at System.Windows.UIElement.Measure_WithDesiredSize(Size availableSize)
            at System.Windows.Controls.VirtualizingStackPanel.MeasureChild(UIElement child, Size layoutSlotSize)
            at System.Windows.Controls.VirtualizingStackPanel.MeasureOverride(Size constraint)

 
And I've narrowed it down to this template:
  <DataTemplate x:Key="pivotJumplistTemplate">
            <l:JumpList
               
 ScrollDuration="400"
               
 ItemsSource="{Binding events}"
               
 ItemTemplate="{StaticResource eventTemplateByDay}"
               
 JumpButtonStyle="{StaticResource AccentColoredButtonStyle}">
                <l:JumpList.CategoryProvider>
                    <l:DistinctPropertyValueCategoryProvider PropertyName="StartTime"/>
                </l:JumpList.CategoryProvider>
            </l:JumpList>
        </DataTemplate>

If I replace this one with the non-jumplist, it works.

        <DataTemplate x:Key="pivotListTemplate">
            <ListBox
               
 ItemsSource="{Binding events}"
               
 ItemTemplate="{StaticResource eventTemplate}">
            </ListBox>
        </DataTemplate>

Aha - and now adding Jumplist to my search,  I get this article from the guy who wrote the control I'm using - 
All the comments say they are seeing this error. Turns out the control is now distributed as part of http://wp7contrib.codeplex.com/, which has been updated for 7.1. Installed the new package with nuget and swapped out my assembly references….and got the same exception.  And so were other people since September - I can't find an indication that he's updated it since then. I left a comment on the post asking if it had been updated. He's responded a couple of times since then saying he is planning to update, but hasn't had time recently.

Fortunately Telerik recently had a special for Microsoft employees, so I got their Windows Phone suite free - I can insert their jumplist instead.

Tuesday, March 6, 2012

public get, private set, public crash?


Goodness,  I seem to have found the weirdest bug. I decided to pull all the event headings into the Schedule class ("Manticore" etc) as a precursor to loading these dynamically from a settings file.  I set up the lists like this:

        
public List<string> eventDays
        {
            
get { return eventDays; }
            
private set { }
        }

However, all of a sudden I found that the app would completely and silently crash, not even throwing an exception for me, when it tried to access any of these list variables - even from within the same class. I removed the get/set so they were just public variables, and the app worked fine again. Then I put back this get/set code, and the app crash reliably reproduced, and then visual studio itself crashed.

    public Schedule()
        {
            
ObservableCollection<Event> events = new ObservableCollection<Event>();
            Events = events;
            eventDays = 
new List<string>();
        }

        private void readSchemaFile()
        {
            
if (eventLocations == null)
            {
                eventLocations = 
new List<String>();
            }
   //populate list
      }


edit: the next day, when it was not 2am, someone pointed out to me that I had obviously put a recursive get on eventDays, so it was crashing with a stack overflow. Way to go, me.