出了什麼問題有以下:XamlReader.Load拋出System.Windows.Markup.XamlParseException
<Run FontWeight=\"Bold\" Foreground=\"#FF0000FF\" xmlns=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\" xml:space=\"preserve\"><Run.TextDecorations><TextDecoration Location=\"Underline\" /></Run.TextDecorations>046/98 5802007513 \r</Run>
雖然類似其他由XamlReader.Load加載罰款,這將引發以下異常:
類型 'System.Windows.Markup.XamlParseException'「第一次機會異常出現在 PresentationFramework.dll
附加INF ormation:給定編碼中的字符無效。 1號線,233位」
代碼複製的問題:
using System;
using System.IO;
using System.Text;
using System.Windows.Markup;
namespace XamlTesting
{
class Program
{
static void Main(string[] args)
{
String str = "<Run FontWeight=\"Bold\" Foreground=\"#FF0000FF\" xmlns=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\" xml:space=\"preserve\"><Run.TextDecorations><TextDecoration Location=\"Underline\" /></Run.TextDecorations>046/98 5802007513 \r</Run>";
Stream s = new MemoryStream(ASCIIEncoding.Default.GetBytes(str));
try
{
var temp = XamlReader.Load(s);
}
catch (Exception ex)
{
Console.WriteLine(ex);
}
}
}
}
我認爲它與雙引號無關是一個反斜槓!它沒有工作。 – Abbas 2015-04-02 07:59:09
嘗試從「98 5802007513」中刪除空格 – user3150546 2015-04-02 08:11:39