views:

2313

answers:

5

Hi,

I am working on localization for a asp.net application that consists of several projects.

For this, there are some strings that are used in several of these projects. Naturally, I would prefer to have only one copy of the resource file in each project.

Since the resource files don't have an namespace (at least as far as I can tell), they can't be accessed like regular classes.

Is there any way to reference resx files in another project, within the same solution?

+2  A: 

Some useful advice on how to manage a situation like this is available here:

http://www.codeproject.com/KB/dotnet/Localization.aspx

Martin
+1  A: 

You can just create a class library project, add a resource file there, and then refer to that assembly for common resources.

Jon Limjap
A: 

Thank you both for your input.

The solution with a class library seems to work quite well.

Only thing is, I have to create a public wrapper function, since the protection level of the resources does not allow them to be accessed directly from outside the assembly.

I don't think this is a deal-breaker, though :)

/Jonas

Joda
you can change that from internal to public
John Nicholas
+2  A: 

I have used this solution before to share a assembley info.cs file across all projects in a solution I would presume the same would work fro a resource file.

Create a linked file to each individual project/class library. There will be only one copy and every project will have a reference to the code via a linked file at compile time. Its a very elegant solution to solve shared non public resources without duplicating code.

<Compile Include="path to shared file usually relative">
  <Link>filename for Visual Studio To Dispaly.resx</Link>
</Compile>

add that code to the complile item group of a csproj file then replace the paths with your actual paths to the resx files and you sould be able to open them.

Once you have done this for one project file you should be able to employ the copy & paste the linked file to other projects without having to hack the csproj.

Mark Harris
A: 

can any one provide the sample code classlibrary method.....