Search code examples
visual-studiovisual-studio-2008projectssolution

Solution with 2 projects - sharing Properties.Resources


In Visual C# 2008, I have a solution with two projects.

First project contains Form1 that displays one Label with Text set to a string from Properties.Resources, like this:

label1.Text = Properties.Resources.MY_TEXT;

In the second project, I "Add as link" this Form1 from the first project. I want to show this form, so it displays the same as when called from the first project. It should show a label with text Properties.Resources.MY_TEXT defined in the first project.

Unfornately, the second project doesn't build with the following error message: "The name 'Properties' does not exist in the current context".

Is there any way how to resolve this? I have tried to "Add as link" the "Resources.resx" file from the first project, but it doesn't help.

EDIT: I found that if I add Project1 as a Reference in Project2, everything works. I also had to change Access Modifier in the Project1 resources from Internal to Public. Is this the right approach?

Thank you, Petr


Solution

  • Yes that is the right approach (referencing one project from another). A pattern you may like to apply is to have one project that has all your reference/lookup/settings in it. Then you don't need to work out dependencies between your UI projects.

    Your approach of making the resources public is the correct.

    You also asked about combining assemblies. Have a look at the ILMerge tool.