Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
AccessViolationException で死ぬコード
<Page
x:Class="App11.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:App11"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Button Content="Fire" Click="Button_Click"/>
<Viewbox x:Name="xamlBox"></Viewbox>
</Grid>
</Page>
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Markup;
// 空白ページの項目テンプレートについては、https://go.microsoft.com/fwlink/?LinkId=402352&clcid=0x411 を参照してください
namespace App11
{
/// <summary>
/// それ自体で使用できる空白ページまたはフレーム内に移動できる空白ページ。
/// </summary>
public sealed partial class MainPage : Page
{
private string text =
"<controls:Canvas xmlns:controls=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\" Height=\"99.681\" Width=\"111.169\">\r\n" +
"</controls:Canvas>";
public MainPage()
{
this.InitializeComponent();
}
private void Button_Click(object sender, RoutedEventArgs e)
{
var xamlObject = XamlReader.Load(text); // ← ここで死ぬ
var xaml = xamlObject as Canvas;
this.xamlBox.Child = xaml;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment