2013-02-18 4 views
0

저는 Windows 8 앱을 구축 중이며 웹 서비스에서 XAML을 구문 분석하여 RichTextBlock에 저장하려고합니다. 이 사용하려면 XamlReader 사용하려고하지만 this code from Microsoft's documentation 내 환경에서 예외를 throw하고 있습니다.XamlReader는 (는) 코드 스 니펫 예외를 throw하고 있습니다.

string xaml = "<Ellipse Name=\"EllipseAdded\" Width=\"300.5\" Height=\"200\" Fill=\"Red\" \"http://schemas.microsoft.com/winfx/2006/xaml/presentation\"/>"; 
object ellipse = Windows.UI.Xaml.Markup.XamlReader.Load(xaml); 
두 번째 줄을 실행할 때, 나는 예외를 얻을

:

An unhandled exception of type 'Windows.UI.Xaml.Markup.XamlParseException' occurred in mscorlib.dll 

WinRT information: illegal qualified name character [Line: 1 Position: 68] 

Additional information: Unspecified error 

VS의 내 버전에서는 Microsoft Visual C# 2012 (마이크로 소프트 비주얼 스튜디오 프리미엄 2012 버전 11.0.51106.01이며, 마이크로 소프트 .NET 프레임 워크 버전 4.5.50709). 설명서에 Windows 8이로드 방법을 지원해야한다고 나와 있습니다. 어떤 아이디어? 자신의 XAML에서 오타가처럼

답변

2

은 같습니다 - 그들은 네임 스페이스 URI 전에 xmlns=을 놓치고 :

string xaml = "<Ellipse" 
    + " Name=\"EllipseAdded\" Width=\"300.5\" Height=\"200\" Fill=\"Red\"" 
    + " xmlns=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\"/>"; 

(라인 읽기 쉽도록 두 줄로.) 그것을했다

+0

그래. 이상하게도, Microsoft에서 복사 붙여 넣기 대신 내 자신의 코드를 사용했을 때 xmlns =를 포함 시켰습니다. 그래도 여전히 숨 막히지 만, 적어도 지금부터는 SOMEWHERE을 사용합니다. 감사! – user460847