【问题标题】:ERROR: No XAML Found at the location '/Protocol' C# Facebook SDK错误:在“/协议”C# Facebook SDK 位置找不到 XAML
【发布时间】:2015-09-19 03:11:11
【问题描述】:

我是 Facebook SDK 的新手

在使用适用于 Windows Phone 8 的 Facebook SDK 单点登录时。我在 WMAppManifest.xml 文件中添加了 <Protocol Name="msft-[AppId]" NavUriFragment="encodedLaunchUri=%s" TaskID="_default" />。但是当我运行调试应用程序时,它会显示一个异常

“在位置 '/Protocol' 未找到 XAML”

我该怎么做才能解决它

【问题讨论】:

    标签: c# facebook facebook-c#-sdk


    【解决方案1】:

    首先我不认为协议名称属性是正确的。基于 MSDN 关于协议名称:自定义 URI 方案中的前缀。长度介于 2 到 39 个字符之间的字符串,包含数字、小写字母、句点 ('.') 或连字符 ('-')。不要在 URI 中包含冒号 (':') 或任何其他将跟在前缀后面的内容。

    除此之外,我相信您正在尝试在不存在的 uri 中导航。我的建议是打破您的自定义 uri 映射器的构造函数。你应该有一个类似于这个的类

    public class CustomUriMapper: UriMapperBase
    {
        public override Uri MapUri(Uri uri)
        {
            // Break into this point to detect the incoming uri and be sure
            // to return a valid xaml page if tempuri contains your protocol name
            string tempUri = uri.ToString();
            string mappedUri = string.Empty;
            // Search for a specific deep link URI keyword
            if (tempUri.Contains("msftappid"))
            {
                // Launch to the mainpage xaml.
                return new Uri("/MainPage.xaml", UriKind.RelativeOrAbsolute);
            }
            // Otherwise perform normal launch.
            Debug.WriteLine("Normal launch detection");
            return uri;
        }
    }
    

    闯入构造函数以检测传入的 uri,如果 tempuri 包含您的协议名称,请确保返回有效的 xaml 页面。在您的示例中,msft-[AppId] 应该是 msftappid

    【讨论】:

      【解决方案2】:

      在这样的扩展下添加协议:

      <Extensions> 
        <Protocol Name="msft-[AppId]" NavUriFragment="encodedLaunchUri=%s" TaskID="_default" /> 
      </Extensions> 
      

      check this sample

      最后给出了相关的博客链接,请检查一下。

      【讨论】:

        【解决方案3】:

        只需转到 App.xaml.cs 并在 InitializePhoneApplication() 中插入以下代码:

        RootFrame.UriMapper = new CallbackUriMapper();
        

        你需要这个来初始化回调类。 (CallbackUriMapper() 就是一个例子。只需将您应用到该类的名称输入即可。

        【讨论】:

          【解决方案4】:

          首先,FB beta 应用程序正在正确调用您的应用程序。而您的 App.xaml.cs 不知道将控件重定向到哪里...因此出现错误。

          索尔:

          我。添加这一行

          RootFrame.UriMapper = new ContosoCallbackUriMapper(); 
          

          在您的 App.xaml.cs 文件中的方法 InitializePhoneApplication() 中。

          二。从 MSDN 页面下载的示例示例中导入此类文件 ContosoCallbackUriMapper.cs。LINK HERE

          并将其添加到您的项目级别。

          它应该可以正常工作..

          如果阅读代码...第 1 步告诉将此类用于任何 URI 映射,n 第 2 步告诉如果 State 已通过身份验证,则将用户重定向到 Main.xaml...

          【讨论】:

            猜你喜欢
            • 1970-01-01
            • 1970-01-01
            • 2017-01-20
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 2018-05-16
            相关资源
            最近更新 更多