5

I have a few lines of code that have worked fine for months, and now suddenly they do not work and I get a very strange error. Here is the function in question:

public void OnCommandsRequested(SettingsPane settingsPane, SettingsPaneCommandsRequestedEventArgs eventArgs) {
        UICommandInvokedHandler handler = new UICommandInvokedHandler(OnSettingsCommand);
        SettingsCommand appSettings = new SettingsCommand("appSettings", "アプリ内設定", handler);
        eventArgs.Request.ApplicationCommands.Add(appSettings);
}

Naturally, this gets called in response to the SettingsPane.GetForCurrentView().CommandsRequested event. The error happens on the second line and is as follows:

A first chance exception of type 'System.FormatException' occurred in mscorlib.dll

Additional information: Guid should contain 32 digits with 4 dashes (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx).

If I continue the app, then another exception comes:

A first chance exception of type 'System.InvalidCastException' occurred in mscorlib.dll

Additional information: Object in an IPropertyValue is of type 'String', which cannot be converted to a 'Guid'.

What is going on here? As you can see I'm not using any GUID values anywhere.

Community
  • 1
  • 1
borrrden
  • 33,256
  • 8
  • 74
  • 109
  • As a point of disambiguation, "second line" is referring to `SettingsCommand appSettings = new SettingsCommand("appSettings", "アプリ内設定", handler);`, correct? The first param is supposed to be an `Object` (but the documentation doesn't seem to list anything about restrictions, and the samples use strings too), maybe try passing a guid? Or perhaps it's trying to construct a guid from the label, and the process doesn't play nice with non-ascii characters? Does it work if you substitute a different label? – Clockwork-Muse Dec 12 '13 at 09:14
  • @Clockwork-Muse You were on the money. If I pass a GUID as the first parameter it works just fine. – borrrden Dec 12 '13 at 09:40
  • ... guess I'm posting that as an answer then, unless somebody has an explanation of _why_ a guid is now required... – Clockwork-Muse Dec 12 '13 at 09:47

1 Answers1

4

Although the documentation lists no restrictions, and all samples use strings, the first parameter is listed as taking Object - it's possible this now is simply set to require a giud.

Interestingly, it looks like this has been reported to Microsoft as a bug in the OS. No idea what the resolution is going to be.

Clockwork-Muse
  • 12,806
  • 6
  • 31
  • 45
  • 1
    Just as an embarrassing tidbit, this exception seems to be handled internally. It was just causing an exception breakpoint. The program continues to run fine. I assumed since an exception breakpoint was reached that the program would fail but it doesn't. – borrrden Dec 12 '13 at 10:02
  • Could be a temporary fix of some sort.... I'd hope the permanent one doesn't need that much overhead. – Clockwork-Muse Dec 12 '13 at 10:07