locked
Problem with making Privacy link in Charms - Visual Basic Window 8.1

    Question

  • I am using a system for the above which has worked on previous apps but now does not seem to work.

    At the beginning I have:

     Public Shared showSettingsCharmOnFlyoutClose As Boolean = True

    In the initialization I have:

      AddPrivacyPolicyLinkToSettingsCharm()

    I then call it below below:

    Private Sub AddPrivacyPolicyLinkToSettingsCharm() AddHandler SettingsPane.GetForCurrentView.CommandsRequested, Sub(sender, e) e.Request.ApplicationCommands.Add(New SettingsCommand("privacypolicy", "Privacy Policy", Sub() LaunchWebPage(New System.Uri("http://windows8cardgames.weebly.com/privacy.html")))) End Sub Public Async Sub LaunchWebPage(ByVal Uri As System.Uri) Await Windows.System.Launcher.LaunchUriAsync(Uri) End Sub

    However when I click on the Charms settings I receive the following error relating to the addhandler:-

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

    Most grateful if somebody could tell me how I can correct my code so that it works.

    Many thanks

    Malcolm Bain

    PS This code has worked fine in earlier apps.



    Malcolm Bain

    • Moved by Carl Cai Tuesday, April 29, 2014 5:14 AM (from debug)More related
    Monday, April 28, 2014 8:02 AM

Answers

  • Running the debugger on the same system can interfere with focus-based behavior since breakpoints will switch from the app to the debugger. You can avoid this by debugging remotely on another system or in the simulator.

    Since you don't care about these exceptions you can also turn off the break when thrown behavior in the Debug.Exceptions... dialog (there should be a link when the exception is hit as well) or you can run without the debugger attached.

    You can build a test package from the Project.Store menu. Go through the same steps as building to upload to the store except choose to build a local package. See Installing developer packages on Windows RT for a run through (pick x86 or AnyCPU instead of ARM to run on a Windows 8 or 8.1 system instead of Windows RT).

    --Rob

    • Marked as answer by Malcnoo Wednesday, April 30, 2014 3:00 PM
    Wednesday, April 30, 2014 2:04 PM
    Owner
  • Many thanks indeed Rob. Problem solved - it worked fine without the debugger -  and I can put up my App tonight. Hope you didn't think I was too thick, it is strange none of this happened before with debugging. They must have done something to the debugger.

    Malcolm


    Malcolm Bain

    • Marked as answer by Malcnoo Wednesday, April 30, 2014 3:06 PM
    Wednesday, April 30, 2014 3:06 PM

All replies

  • Hi,

    I am moving this thread to Building Windows Store apps with C# or VB  forum for better supports.

    Thanks for your understanding.

    Regards.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, April 29, 2014 5:15 AM
  • The code you list here appears correct and works fine for me in a test app. It doesn't appear to do anything that would trigger the error you mention.

    Where do you have this code? When do you get the error? On what line? Why do you think that is related to the AddHandler, and in what way do you think it is related?

    I'd look at the context of the rest of the class that this is in. If you can reproduce the problem in a minimal app and share that app on your OneDrive we can take a closer look.

    --Rob

    Tuesday, April 29, 2014 6:02 AM
    Owner
  • Thank you for your help. As you suggest I have written the code in a minimal app called test, placing the code where I have it in my app on MainPage. I get the same error in green on this line:

    AddHandler SettingsPane.GetForCurrentView.CommandsRequested, Sub(sender, e) e.Request.ApplicationCommands

    Error message:-

    An exception of type 'System.InvalidCastException' occurred in mscorlib.dll and wasn't handled before a managed/native boundary

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

    It happens as soon as I click on Settings in the charms.

    I do not know the answer to your query about AddHandler as I did not write the code myself obtaining it a long time ago searching the web. As I said it has worked fine on previous apps.

    Perhaps I am putting the code in the wrong place?

    I already had a link to the Privacy page with a button on Main Page but MS rejected my app and said I must have it in charms.

    I have added a  zip of my minimal app Test to my OneDrive but do not have an email address to share with you.

    However the code is as follows:-

    Imports Windows.UI.ApplicationSettings
    
    ' The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238
    
    ''' <summary>
    ''' An empty page that can be used on its own or navigated to within a Frame.
    ''' </summary>
    Public NotInheritable Class MainPage
        Inherits Page
        Public Shared showSettingsCharmOnFlyoutClose As Boolean = True
        'AddPrivacyPolicyLinkToSettingsCharm()
        Public Sub New()
            InitializeComponent()
            AddPrivacyPolicyLinkToSettingsCharm()
        End Sub
        Private Sub AddPrivacyPolicyLinkToSettingsCharm()
            AddHandler SettingsPane.GetForCurrentView.CommandsRequested, Sub(sender, e) e.Request.ApplicationCommands.Add(New SettingsCommand("privacypolicy", "Privacy Policy", Sub() LaunchWebPage(New System.Uri("http://windows8cardgames.weebly.com/privacy.html"))))
        End Sub
        Public Async Sub LaunchWebPage(ByVal Uri As System.Uri)
            Await Windows.System.Launcher.LaunchUriAsync(Uri)
        End Sub
    End Class

    Many thanks

    Malcolm


    Malcolm Bain

    Tuesday, April 29, 2014 9:03 AM
  • Tuesday, April 29, 2014 10:04 AM
  • The exceptions you're describing aren't errors. They are thrown and handled inside the framework. You can ignore them.

    This isn't specific to your code. If you look at the App settings sample  it has the same behavior.

    --Rob

    Wednesday, April 30, 2014 12:48 AM
    Owner
  • Rob

    Thanks, you are right it does the same thing with the App settings sample. So I just clicked Continue when it happened and it continues without crashing but does not display the settings at all just goes back to the MainPage. Ever time one clicks settings this is what happens. Are we saying that it will work after it has been packaged? How can one check that it is indeed working before putting it up - again - to the store? Is it possible to make a package and then run it to check?

    Malcolm


    Malcolm Bain

    Wednesday, April 30, 2014 5:28 AM
  • Running the debugger on the same system can interfere with focus-based behavior since breakpoints will switch from the app to the debugger. You can avoid this by debugging remotely on another system or in the simulator.

    Since you don't care about these exceptions you can also turn off the break when thrown behavior in the Debug.Exceptions... dialog (there should be a link when the exception is hit as well) or you can run without the debugger attached.

    You can build a test package from the Project.Store menu. Go through the same steps as building to upload to the store except choose to build a local package. See Installing developer packages on Windows RT for a run through (pick x86 or AnyCPU instead of ARM to run on a Windows 8 or 8.1 system instead of Windows RT).

    --Rob

    • Marked as answer by Malcnoo Wednesday, April 30, 2014 3:00 PM
    Wednesday, April 30, 2014 2:04 PM
    Owner
  • Many thanks indeed Rob. Problem solved - it worked fine without the debugger -  and I can put up my App tonight. Hope you didn't think I was too thick, it is strange none of this happened before with debugging. They must have done something to the debugger.

    Malcolm


    Malcolm Bain

    • Marked as answer by Malcnoo Wednesday, April 30, 2014 3:06 PM
    Wednesday, April 30, 2014 3:06 PM