出了什么问题有以下: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