windows-phone-7 – 错误:System.Windows.ni.dll中出现’System
发布时间:2020-12-14 05:54:34 所属栏目:Windows 来源:网络整理
导读:我有 windows手机应用程序;当我运行应用程序时,我得到了这个异常并且它不再运行了 A first chance exception of type 'System.Windows.Markup.XamlParseException' occurred in System.Windows.ni.dll 错误发生在intializecomponent()中的app.xaml文件中;方
我有
windows手机应用程序;当我运行应用程序时,我得到了这个异常并且它不再运行了
A first chance exception of type 'System.Windows.Markup.XamlParseException' occurred in System.Windows.ni.dll 错误发生在intializecomponent()中的app.xaml文件中;方法 public App() { // Global handler for uncaught exceptions. UnhandledException += Application_UnhandledException; // Standard XAML initialization InitializeComponent(); // Phone-specific initialization InitializePhoneApplication(); 由于我在添加应用程序资源时发生错误 <converter:RssTextTrimmer xmlns:converter="clr-namespace:HomePage" x:Key="RssTextTrimmer" /> 当我删除它时,应用程序运行良好. 以下是完整代码: <Application x:Class="HomePage.App" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone" xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"> <!--Application Resources--> <Application.Resources> <local:LocalizedStrings xmlns:local="clr-namespace:HomePage" x:Key="LocalizedStrings"/> <converter:RssTextTrimmer xmlns:converter="clr-namespace:HomePage" x:Key="RssTextTrimmer" /> </Application.Resources> <Application.ApplicationLifetimeObjects> <!--Required object that handles lifetime events for the application--> <shell:PhoneApplicationService Launching="Application_Launching" Closing="Application_Closing" Activated="Application_Activated" Deactivated="Application_Deactivated"/> </Application.ApplicationLifetimeObjects> 转换器代码 命名空间HomePage // Clean up text fields from each SyndicationItem. public object Convert(object value,Type targetType,object parameter,CultureInfo culture) { if (value == null) return null; int maxLength = 200; int strLength = 0; string fixedString = ""; // Remove HTML tags and newline characters from the text,and decodes HTML encoded characters. // This is a basic method. Additional code would be needed to more thoroughly // remove certain elements,such as embedded Javascript. // Remove HTML tags. fixedString = Regex.Replace(value.ToString(),"<[^>]+>",string.Empty); // Remove newline characters fixedString = fixedString.Replace("r","").Replace("n",""); // Remove encoded HTML characters fixedString = HttpUtility.HtmlDecode(fixedString); strLength = fixedString.ToString().Length; // Some feed management tools include an image tag in the Description field of an RSS feed,// so even if the Description field (and thus,the Summary property) is not populated,it could still contain HTML. // Due to this,after we strip tags from the string,we should return null if there is nothing left in the resulting string. if (strLength == 0) { return null; } // Truncate the text if it is too long. else if (strLength >= maxLength) { fixedString = fixedString.Substring(0,maxLength); // Unless we take the next step,the string truncation could occur in the middle of a word. // Using LastIndexOf we can find the last space character in the string and truncate there. fixedString = fixedString.Substring(0,fixedString.LastIndexOf(" ")); } fixedString += "..."; return fixedString; } // This code sample does not use TwoWay binding and thus,we do not need to flesh out ConvertBack. public object ConvertBack(object value,CultureInfo culture) { throw new NotImplementedException(); } } } 解决方法
在您的RssTextTrimmer.cs文件中,确保该类是公共的 “公共课RssTextTrimmer:IValueConverter” 不 “class RssTextTrimmer:IValueConverter” 这就是我的烦恼
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- windows-8 – WinRT应用程序可以使用混淆吗?
- 哪个Windows版本的Windows ANSI Western(cp 1252)首次出现?
- windows – 无法将2012服务器添加到2003域,因为它表示forre
- window的渊源、发展过程、趋势
- WPF.抓住最后一个窗口点击任意位置
- xaml – CollectionViewSource“值不在预期范围内.”
- 如果结构定义了uint16_t字和uint8_t字节,则数组的大小加倍
- windows-server-2003 – 创建与Windows 2003 PDC服务器的SA
- windows – `RegisterDragDrop`返回S_OK,但没有调用方法Dra
- window设置TortoiseGit连接git不用每次输入用户名和密码
推荐文章
站长推荐
- windows-server-2012-r2 – Windows 2012 DNS服务
- windows-phone-8 – 使用远程图像创建CycleTile
- 使用命令行在Windows RabbitMQ节点上创建vHost
- group-policy – 以编程方式或通过脚本“触摸”软
- opengl-es – 我可以在Windows Phone 8应用程序中
- windows-7 – 如何在不刻录DVD或使用USB驱动器的
- windows-server-2008-r2 – 虚拟(ESXi4)Win 2k8
- 使用Burn作为WiX对话框和自定义操作的替代方法
- windows – 无边框窗口.如何添加阴影并删除1px边
- 如何在Windows 7中使一个服务依赖于另一个服务?
热点阅读