ERROR: No XAML Found at the location '/Protocol' C#
本文关键字:Protocol location the No XAML Found at ERROR | 更新日期: 2023-09-27 18:02:55
我是Facebook SDK新手
在使用Windows Phone 8的Facebook单点登录SDK时。我在WMAppManifest.xml文件中添加了 <Protocol Name="msft-[AppId]" NavUriFragment="encodedLaunchUri=%s" TaskID="_default" />
。但是当我运行调试应用程序时,它显示了一个异常
"在位置'/Protocol'没有找到XAML "
我该怎么解决呢
首先我不认为协议名称属性是正确的。基于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。
在扩展名下添加协议:
<Extensions>
<Protocol Name="msft-[AppId]" NavUriFragment="encodedLaunchUri=%s" TaskID="_default" />
</Extensions>
检查这个示例
最后给出了相关的博客链接,请查收
进入app . example .cs,在InitializePhoneApplication()中插入以下代码:
RootFrame.UriMapper = new CallbackUriMapper();
你需要这个来初始化回调类。(CallbackUriMapper()就是一个例子。
首先,FB beta应用程序调用你的应用程序正确。和你的app . example .cs不知道在哪里重定向控件…因此出现了错误。
索尔:
。添加这一行
RootFrame.UriMapper = new ContosoCallbackUriMapper();
在方法InitializePhoneApplication()中的 app . example .cs文件。
二世。从MSDN页面下载的示例中导入这个类文件ContosoCallbackUriMapper.cs。链接
并将其添加到您的项目级别。
它应该工作得很好。
如果读取代码…第一步告诉使用这个类的任何URI映射,n,步骤2告诉,如果状态被认证,重定向用户到Main.xaml…