locked
Why does using 'WrapToWholeWords' crash my app? RRS feed

  • Question

  • I spent ages debugging an app that was constantly crashing shortly after launch. The app only crashed on Windows 8.0 (worked fine on Windows 8.1 Preview, which I had, unfortunately, done my developing and testing). The app is targeted at Windows 8.0, NOT 8.1.

    After a lengthy trial-and-error session I figured out that the cause of the crash was the 'WrapWholeWords' setting in a textblock in my XAML. There was no indication of a problem with the XAML (no wiggly lines), and the value was set from the properties panel, not added manually.

    Changing to 'Wrap' fixed the problem completely on Windows 8.0.

    My question is why would something like this crash the app? Is it simply the wrapping causing the text to not fit in the textblock (it's within a datatemplate where the 'size' of the text can vary)? Is there something wrong with using this setting? Or is it simply a XAML bug in Windows 8.0/VS2012?


    I'm a self-taught noob amateur. Please take this into account when responding to my posts or when taking advice from me.

    Friday, August 23, 2013 1:43 AM

Answers

All replies

  • WrapWholeWords was added to the TextWrapping enum in the 8.1, so the value does not exist when targeting 8.0.

    http://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.xaml.textwrapping.aspx

    What was the exception you were seeing when the app crashed?  Was it not helpful at all?

    • Marked as answer by pumpkinszwan Monday, September 2, 2013 8:19 AM
    Friday, August 23, 2013 2:37 AM
  • Thanks for the answer, Matt. It makes sense that it would crash 8.0 if it was only added in 8.1.

    And I know it's my own fault for developing in 8.1 with VS2013 and testing on 8.1 devices when targeting 8.0...but if VS2013 and Windows 8.1 weren't such big improvements over their predecessors it wouldn't be an issue :)

    However, the crash was not helpful at all. It was one of those generic errors that you know must be a XAML issue but can't find...off the top of my head it was a "value out of range or unexpected" (not at my dev PC right now). I had to literally swap blocks of XAML in and out from an earlier version until I narrowed down which part of code the problem was in. But it was a great learning experience I suppose.

    So why does the app still compile and run correctly from VS2012 (including passing the package creation tests for upload to the store)? Why doesn't the incorrect value get wiggly lines in the XAML?



    I'm a self-taught noob amateur. Please take this into account when responding to my posts or when taking advice from me.

    Friday, August 23, 2013 2:48 AM
  • Windows 8 only supports apps developed on Windows 8 with VS 2012. This because your app code may contain an 8.1 feature or API that did not exist in 8, like the WrapToWords enum value. Windows 8 has no concept of this and will then fail with a XamlParseException or InvalidValueException, I am not sure what exactly you were seeing. 

    The goal is to enable apps developed on and for Windows 8 to run with no issues or noticeable differences on Windows 8.1.  If you are developing on Windows 8.1 you are able to target Windows 8.0 or 8.1 behaviors depending on which version of VS you are using. VS2012 will target the version 8.0 for apps and VS2013 will target 8.1.  The goal is not to enable an app with new 8.1 features to run on Windows 8.

    Monday, August 26, 2013 4:17 PM
  • If you are developing on Windows 8.1 you are able to target Windows 8.0 or 8.1 behaviors depending on which version of VS you are using. VS2012 will target the version 8.0 for apps and VS2013 will target 8.1.

    Unfortunately VS2012 (running on 8.1) allows me to select the WrapWholeWords value in a project targeted to Windows 8.0 (from the Properties drop-down - I didn't enter this value manually).  The value is not available in VS2012 on Windows 8.0. I don't understand why the feature availability is determined by the OS being developed on rather than the target OS.

    This creates a potential trap, especially given that the 8.0 app will actually compile, pass the tests, and run perfectly on the 8.1 development machine, giving the developer no hint that it will fail to run on an 8.0 device; and when it does fail on an 8.0 device the error given is vague and difficult to track down (it doesn't specify where the error occurs, and the XAML is not marked as incorrect). At least for a novice like myself I was only able to find the source of the error by methodical trial-and-error.

    If a value is illegal in an 8.0 app it should not be selectable when targeting 8.0 in my opinion, regardless of which Visual Studio version is being used and on which Windows version development occurs. Is this behaviour actually by design? I'm well aware there could be good reasons that I'm simply unaware of (I'm an inexperienced noob)...but it seems counter intuitive.


    I'm a self-taught noob amateur. Please take this into account when responding to my posts or when taking advice from me.

    Tuesday, August 27, 2013 12:18 AM