我试图在Windows Phone应用程序加载图像
这里从嵌入式资源加载图像是我的项目设置:
模块1 = Phone应用程序
单词数= ClassLibrary.dll
Module1调用Module2为手机应用程序创建所有数据对象。
当Module2创建对象时,我想从资源加载图像。
资源是“为Default.png”,并保存在“图像”目录(生成操作=嵌入的资源,复制到输出目录=一直拷贝)
我使用的代码产生一个异常
ex = {"The request is not supported. "}
下面是代码:
private void LoadImage()
{
Assembly curAssembly = null;
curAssembly = Assembly.GetExecutingAssembly();
string [] names = curAssembly.GetManifestResourceNames();
// names[0] = "Storage.Images.Default.png"
// so I know I am using the correct name
Stream resStream = curAssembly.GetManifestResourceStream("Storage.Images.Default.png");
BitmapImage bitMapImage = new BitmapImage();
try
{
bitMapImage.SetSource(resStream);
}
catch (Exception ex)
{
Debug.WriteLine(ex.ToString());
}
}
你能帮助一个新手了呢? 感谢
谢谢你的方法...我会给这些尝试...但他们不回答我的问题,为什么我无法加载资源,即使资源在模块内,如GetManifestResourceNames所示? – user3174075