我可以在同一解决方案中从其他项目访问另一个项目的嵌入式资源吗? [英] Can I access another project's Embedded Resource from a different project in the same solution?

查看:81
本文介绍了我可以在同一解决方案中从其他项目访问另一个项目的嵌入式资源吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个xml文件,作为Project_A中的嵌入式资源。

I have one xml file that stands as an embedded resource in Project_A.

我想从引用了Project_A的Project_B中获取此嵌入式资源。

And I want to reach this embedded resource from Project_B which references Project_A.

(基本上Project_B包含单元测试,我使用ReSharper运行它们。)

(Basically Project_B consists of unit tests and I run them with ReSharper.)

是否可以访问Project_A的嵌入式资源

Is it possible to access embedded resource of Project_A when I am working on Project_B?

或者一般来说,我可以在同一解决方案中从其他项目访问另一个项目的嵌入式资源吗?

Or in general, can I access another project's Embedded Resource from a different project in the same solution?

推荐答案

是的,可以。这是一个示例,您如何在.NET Framework的 System.dll System.Timers.Timer.bmp c $ c>:

Yes, you can. Here is an example, how you can get the embedded resource System.Timers.Timer.bmp inside of the .NET Framework's System.dll:

using (Stream stream = typeof(System.Timers.Timer).Assembly.
                           GetManifestResourceStream("System.Timers.Timer.bmp"))
{
    using (Bitmap bitmap = new Bitmap(stream))
    {
        //bitmap.Dump();
    }
}

...或获取资源列表名称:

... or to get the list of the resource names:

string[] names = typeof(System.Timers.Timer).Assembly.GetManifestResourceNames();

...只需替换 typeof(System.Timers.Timer),其程序集内部的类型包含您的嵌入资源

... just replace typeof(System.Timers.Timer) with a type inside of the assembly containing your embedded resources.

这篇关于我可以在同一解决方案中从其他项目访问另一个项目的嵌入式资源吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆