C # - Resource file exchange between projects

I would like two, how to do to share resource files between 2 (or more) projects?

So, to resume work, I have three projects:

development project (CF.NET), which includes a resource file (with all the definition).

I have two other projects that are empty, but the links to development projects are just different builds every time, so when I change the development project, all three projects are also updated. (Modification of the csproj file.)

The question is, regarding resource files? When I try to access from a development project, I get all the resources, but when I try to use 2 others, it throws a "MissingManifestResourceException".

Any idea how to solve this problem?

Thanks.


[EDIT]

Here is what I did:

Create a project named "RealProject" that contains all the code (including resource files) Create a project called "LinkedProject" that doesn't contain anything (I deleted all the files into it and changed the csproj file as follows:

<ItemGroup> <Compile Include="..\RealProject\**\*.cs" /> </ItemGroup> 

So, in the LinkedProject directory, I only:

  • [Directory] bin
  • [Catalog] obj
  • [File] LinkedProject.csproj

In general, LinkedProject uses RealProject files, it's just a different configuration (see here to find out why: C # is a code compiler for .NET and CF.NET )

Once in this configuration I don't have access to resource files from RealProject ...

If you need screens or a more detailed explanation, just ask.


[EDIT]

With this code it works, the resource manager does not load in the name of a good build, but it should have a better solution.

 Assembly ass = Assembly.ReflectionOnlyLoadFrom(@"..\..\..\RealProject\bin\Debug\RealProject.dll"); ResourceManager manager = new ResourceManager("RealProject.Properties.Resources", ass); 

[Decision]

What you need to check:

  • LinkedProject as the same namespace as RealProject
  • Add resources as links
  • Clear all your decisions.
  • Restore it

Test!

+7
source share
2 answers

Try adding the resource file as a reference to two other projects and make sure that the namespace as defined in the project file is the same.

+7
source

Try adding the existing file to other projects as a link.

+1
source

All Articles