xamlのエラー
-
2012年1月30日 2:25
VSでxamlを編集したら下記のようなエラーが発生しました。
型 Universe はアセンブリを解決できません: System.Windows.Controls, Version=2.0.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35。
コンパイル実行すると正常に実行されxamlも表示されます。
気持ち悪いので解決方法をご教授願いますでしょうか?
- 種類を変更済み 山本春海Moderator 2012年2月9日 1:21 自己解決されているようなので、ステータスを変更させていただきました。
すべての返信
-
2012年1月30日 3:00
下記がxamlのソースコードとなります。
なにか分かりますでしょうか?
プロジェクト名は「XXXXXXXXX」としてふせております。
--------------------------
<phone:PhoneApplicationPage
x:Class="XXXXXXXXX.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.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"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:toolkit="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Toolkit"
mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="768"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
SupportedOrientations="Portrait" Orientation="Portrait"
shell:SystemTray.IsVisible="True">
<!--shell:SystemTray.ProgressIndicator>
<shell:ProgressIndicator x:Name="progress" IsIndeterminate="True" IsVisible="False" Text="Loading..." />
</shell:SystemTray.ProgressIndicator-->
<phone:PhoneApplicationPage.Resources>
<DataTemplate x:Key="ItemTemplate">
<StackPanel Height="180" Width="230" HorizontalAlignment="Left" VerticalAlignment="Top">
<Image Source="{Binding Image}" Height="200" Width="200" VerticalAlignment="Top" Margin="0,-20,0,20" HorizontalAlignment="Left"/>
<!--Image Source="{Binding ImageSource}" HorizontalAlignment="Left" Height="200" Width="200"/-->
</StackPanel>
</DataTemplate>
<ItemsPanelTemplate x:Key="ItemsPanelTemplate1">
<!--StackPanel/-->
<toolkit:WrapPanel/>
</ItemsPanelTemplate>
<Style x:Key="ButtonStyle1" TargetType="Button">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Grid>
<Image Source="reina_toda.jpg" Stretch="Fill"/>
<ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Height="26" Width="79"/>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="ButtonStyle2" TargetType="Button">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Grid>
<Image Source="noriko0924.jpg" Stretch="Fill"/>
<ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Height="26" Width="79"/></Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="ButtonStyle3" TargetType="Button">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Grid>
<Image Source="mariko_dayo.jpg" Stretch="Fill"/>
<ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Height="26" Width="79"/></Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="ButtonStyle4" TargetType="Button">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Grid>
<Image Source="sayu0407.jpg" Stretch="Fill"/>
<ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Height="26" Width="79"/>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="ButtonStyle5" TargetType="Button">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Grid>
<Image Source="kagura_xxx.jpg" Stretch="Fill"/>
<ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Height="26" Width="79"/>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="ButtonStyle6" TargetType="Button">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Grid>
<Image Source="y____ui.jpg" Stretch="Fill"/>
<ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Height="26" Width="79"/></Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style></phone:PhoneApplicationPage.Resources>
<!--LayoutRoot は、すべてのページ コンテンツが配置されるルート グリッドです-->
<Grid x:Name="LayoutRoot" Background="Transparent" DataContext="{Binding Source={StaticResource SampleDataSource}}">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions><!--TitlePanel は、アプリケーション名とページ タイトルを格納します-->
<StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">
<TextBlock x:Name="ApplicationTitle" Text="マイ アプリケーション" Style="{StaticResource PhoneTextNormalStyle}"/>
<TextBlock x:Name="PageTitle" Text="ページ名" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
</StackPanel><!--ContentPanel - 追加コンテンツをここに入力します-->
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
<Button x:Name="Button1" Content="" HorizontalAlignment="Left" Height="115" Margin="65,59,0,0" Style="{StaticResource ButtonStyle1}" VerticalAlignment="Top" Width="120" Click="Button1_Click" />
<Button x:Name="Button2" Content="" Height="115" Margin="0,60,80,0" Style="{StaticResource ButtonStyle2}" VerticalAlignment="Top" HorizontalAlignment="Right" Width="120" Click="Button2_Click" />
<Button x:Name="Button3" Content="" HorizontalAlignment="Left" Margin="67,218,0,274" Style="{StaticResource ButtonStyle3}" Width="120" Click="Button3_Click" />
<Button x:Name="Button4" Content="" Margin="0,217,84,275" Style="{StaticResource ButtonStyle4}" HorizontalAlignment="Right" Width="120" Click="Button4_Click" />
<Button x:Name="Button5" Content="" HorizontalAlignment="Left" Margin="68,0,0,107" Style="{StaticResource ButtonStyle5}" Width="120" Height="115" VerticalAlignment="Bottom" Click="Button5_Click" />
<Button x:Name="Button6" Content="" Margin="0,0,83,106" Style="{StaticResource ButtonStyle6}" Height="115" VerticalAlignment="Bottom" HorizontalAlignment="Right" Width="120" Click="Button6_Click" />
</Grid>
</Grid>
<!--ApplicationBar の使用法を示すサンプル コード-->
<!--<phone:PhoneApplicationPage.ApplicationBar>
<shell:ApplicationBar IsVisible="True" IsMenuEnabled="True">
<shell:ApplicationBarIconButton IconUri="/Images/appbar_button1.png" Text="Button 1"/>
<shell:ApplicationBarIconButton IconUri="/Images/appbar_button2.png" Text="Button 2"/>
<shell:ApplicationBar.MenuItems>
<shell:ApplicationBarMenuItem Text="MenuItem 1"/>
<shell:ApplicationBarMenuItem Text="MenuItem 2"/>
</shell:ApplicationBar.MenuItems>
</shell:ApplicationBar>
</phone:PhoneApplicationPage.ApplicationBar>--></phone:PhoneApplicationPage>
-
2012年1月30日 6:03モデレータ
プロジェクトのプロパティで、対象のフレームワークが「.NET Framework 4 Client Profile」であれば、「.NET Framework 4」にすると解決するかもしれません。
★良い回答には回答済みマークを付けよう! わんくま同盟 MVP - Visual C# http://d.hatena.ne.jp/trapemiya/ -
2012年1月30日 8:00
このプロジェクトは、Windows Phone アプリケーションのものでしょうか。
だとすれば、Silverlight Toolkitの参照がWindows Phone用になっていないことが気になります。
http://silverlight.codeplex.com/releases/view/75888 を確認の上、Windows Phone版を利用してください。
(誤) xmlns:toolkit="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Toolkit"
↓
(正) xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
この投稿は現状のまま何の保証もなく掲載しているものであり、何らかの権利を許諾するものでもありません。コミュニティにおけるマイクロソフト社員による発言やコメントは、マイクロソフトの正式な見解またはコメントではありません。詳しくは http://www.microsoft.com/japan/communities/msp.mspx をご覧ください。 -
2012年1月31日 10:44
お忙しい中ご連絡頂きありがとうございます。
本プロジェクトはWindows Phoneアプリケーション用とリリースする予定です。
プロジェクト作成時にWindows Phoneアプリケーションを選択したような気がします。。。
ご指摘頂いた点について修正し
ビルド/リビルドしましたが状況は変わりませんでした。
-
2012年1月31日 19:42
参照設定のほうは見直されましたか?
きちんと Microsoft.Phone.Controls.Toolkit が参照設定に含まれていますか?また、Windows Phone Toolkit のバージョンは最新のものになっていますか?
http://silverlight.codeplex.com/releases今回エラーになっている System.Windows.Controls はXamlのコードからもわかるとおり、Windows Phone Toolkit のライブラリです。
この相手が見つからない(=アセンブリを解決できない)ということは、適したライブラリが参照できないということです。この際に疑うのは、次の2点です。・ Xaml側で正しくNamespaceが(参照)設定されているか
・ そもそも正しいライブラリが参照されているか(対象プラットフォーム違い、バージョン違い)Xaml側は修正したと思いますので、あとは参照しているライブラリの確認が必要です。仮に、Microsoft.Phone.Controls.Toolkit が参照されていたとしても、それが古いバージョンであった場合、同様の問題を引き起こす場合があります。Microsoft.Phone.Controls.Toolkit のプロパティのパスを見ればどのバージョンかわかると思います。
例:C:\Program Files (x86)\Microsoft SDKs\Windows Phone\v7.1\Toolkit\Nov11\Bin\Microsoft.Phone.Controls.Toolkit.dll
-
2012年2月1日 8:58
VSを再起動したら直りました。
お騒がせしました。

