locked
Skydrive can't work in the Windows Runtime Component.

    Question

  • We implement the SkyDrive function in the Metro WPF version. And we try to reuse the code in the Metro JavaScript project. So we wrap a Windows Runtime Component and JavaScript reference the component.

    We write follow code in the component:

     _authClient = new LiveAuthClient();
                try
                {
                    LiveLoginResult authResult = await _authClient.LoginAsync(new string[] { "wl.signin", "wl.contacts_skydrive", "wl.skydrive_update" });
                    if (authResult.Status == LiveConnectSessionStatus.Connected)
                    {
                        bResult = true;
                        liveClient = new LiveConnectClient(authResult.Session);
                        // await LoadUserProfile();
                        // await LoadSkyDriveEpubBookInfo();
                    }
                }
                catch
                {
                }

    It work well in Metro WPF version. But It can't work in the Windows Runtime Component. The "authResult" value always null now.

    Tuesday, August 21, 2012 7:16 AM

Answers

All replies

  • Hi G,

    JavaScript is not being used here.  This is C# code.  You have listed no code from that component so it is impossible to assist you.  Also note you can only pass WinRT types across WinMD so that is probably your issue.  Please see this documentation:

    http://msdn.microsoft.com/en-us/library/windows/apps/hh441572(v=vs.110).aspx

    http://msdn.microsoft.com/en-us/library/windows/apps/br230301.aspx#DeclaringTypes

    -Jeff


    Jeff Sanders (MSFT)

    Tuesday, August 21, 2012 1:10 PM
    Moderator
  • Yes I realized I cannot call LoginAsync from my WinMD for some reason, so I placed the login code in my JavaScript project since i'm creating a hybrid application. (Is there a way to get this to work?)

    However, afterwards I intend to pass the LiveConnectSession obtained from logging in, from my JavaScript Modern app project to my C# winMD for use in creating LiveConnectClient objects for skydrive operations.

    My method that expects the LiveConnectSession has a signature as such

    public void InitSkydriveHelper (object session)
    {
        LiveConnectClient client = new LiveConnectClient((LiveConnectSession) session);
    }

    The above code works when I call it from a C# modern app project but does NOT work when I call it from a JavaScript Modern app project I get Type Mismatch exception. This is strange since it works in C# project.

    I know I cannot pass non WinRT Types but I read somewhere you can use object externally and cast appropriately which again works in C# modern project but not from javascript.

    Whats the way forward. I already have a lot of code invested in my WinMD "Skydrive helper" and converting it all to JavaScript is not the way I want to go. Besides, I want to keep my UI separate from my logic.

    Thanks


    Tuesday, November 27, 2012 11:38 PM