場合
2 つのアセンブリがあります。1 つはアプリケーションを保持し、もう 1 つはライブラリとして機能します。ライブラリは、ビルドアクションがresourceに設定された「Images/image.png」などの画像リソースを保持します。
としょうかん
その次に、ライブラリには SomeStyle.xaml ファイルが含まれています。
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Image x:Key="someKey" Source="/LibraryAssemblyHere;component/Images/image.png" />
</ResourceDictionary>
応用
アプリケーション アセンブリには、次の App.xaml があります。
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/LibraryAssemblyHere;component/Styles/SomeStyle.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
問題
アプリケーションを起動すると、Visual Studio 2010 で次のエラーが表示されます。
Failed to create a 'ImageSource' from the text '/LibraryAssemblyHere;component/Images/image.png
内部例外あり:
Cannot locate resource 'images/image.png'.
質問
シンプル:何が間違っているのでしょうか? 私は検索して検索しましたが、何も役に立ちませんでした。
前もって感謝します!