从另一个项目 C# .Net 访问资源文件 [英] Accessing a resource file from another project C# .Net

查看:32
本文介绍了从另一个项目 C# .Net 访问资源文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好:我在解决方案中有 2 个项目.项目 A 和项目 B.B 引用了 A.因此 A 使用 B 的类和函数.B 没有任何资源文件,因为它只包含所有业务功能.A 包含所有资源文件.我需要使用从 An 到 B 的资源文件.我不能在 B 中引用 A.我部署了我的主项目,它引用了 B.但是如何在不引用 B 中的 A 库的情况下将(A 项目的)资源文件引用到 B 项目中.提前致谢

Hi There: I have 2 projects in a solution. Project A and Project B. B has a reference to A. Thus A uses B's class and functions. B does not have any resource files as it contains all business functions only. A contains all the resource files. I need to use a resource file from An into B. I CAN NOT refer to A in B. I deploy my main project and it has referred to B. But how can I refer to a resource file(of A project) into B project without referencing the A library in B. Thanks in advance

推荐答案

哇,我终于通过搜索找到了.从 B,我链接了 A 中的资源文件.右键单击 B-添加-现有项目-浏览 A(myresrc-en.resx 和我的 myresrc-fr.resx)-为两者添加链接.现在在 B,

Wow, I finally found it from some search. From B, I Linked the resource file in A. Right Click B-Add-Existing Item-Browse the resource file in A(myresrc-en.resx and my myresrc-fr.resx)-Add a Link for both. Now in B,

ResourceManager rmg=new ResourceManager("B.myresrc", Assembly.GetExecutingAssembly());
string str1 = rmg.GetString("resxTxt");   // resxTxt is any string in your resx file.

它工作得很好.保持A中的原始资源不变.这些已经是嵌入式资源.

It worked perfect. Keep original resources in A unchanged. These were already Embedded Resource.

享受吧!

这篇关于从另一个项目 C# .Net 访问资源文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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