大佬教程收集整理的这篇文章主要介绍了windows-phone-7 – 错误:System.Windows.ni.dll中出现’System.Windows.Markup.XamlParseException’类型的第一次机会异常,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
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://scheR_195_11845@as.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://scheR_195_11845@as.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
{
class RSSTextTrimmer:IValueConverter
{
// 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(); } }
}
以上是大佬教程为你收集整理的windows-phone-7 – 错误:System.Windows.ni.dll中出现’System.Windows.Markup.XamlParseException’类型的第一次机会异常全部内容,希望文章能够帮你解决windows-phone-7 – 错误:System.Windows.ni.dll中出现’System.Windows.Markup.XamlParseException’类型的第一次机会异常所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。