'Accessing a resource file from another project C# .Net

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



Solution 1:[1]

Wow, I finally found it from searching online.

I Linked the resource file in Project A to Project B.

Right Click Project B and "Add-Existing Item" then Browse the resource file in Project A

(myresrc-en.resx and my myresrc-fr.resx)

Add a Link for both. Now in Project B


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

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

Enjoy!

Solution 2:[2]

You could add a reference to the project that contains the resource file. However, to use the resource file which is generated as an internal class by default (inaccessible in your project if it's under a different namespace), you need to change the access modifier to public. See https://stackoverflow.com/a/4274341/3666333

Solution 3:[3]

You could create a separate project C containing the resources that both A and B can use.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Developing Developer
Solution 2 Yazan Khalaileh
Solution 3 Mark