views:

27

answers:

2

Hi, I have a problem with resource file...

I have a solution with two projects. The first project contains ImageResource.resx file with my images what I use. Every Form in this project can access to this file from designer. But I can see in the designer ImageResource.resx file to use it from second project (Reference to second project is present).
I've add the ImageResource.resx file as a link to my second project. And I saw it in the designer! But when I use some image from this resource in second project VS modified my original file (It sets the namespaces, and other..) and my solution brokes. Also VS say me that ImageResource.resx has present in two dll's first_project.dll and second_project.dll

Onybody can help me How to correctly use shared resource between projects?

thanks!

A: 

Can you use a symbolic link to share the file into multiple folders?

windows:

mklink linked_location\ImageResource.resx original_location\ImageResource.resx


C:\Users\preet>mklink
Creates a symbolic link.

MKLINK [[/D] | [/H] | [/J]] Link Target

        /D      Creates a directory symbolic link.  Default is a file
                symbolic link.
        /H      Creates a hard link instead of a symbolic link.
        /J      Creates a Directory Junction.
        Link    specifies the new symbolic link name.
        Target  specifies the path (relative or absolute) that the new link
                refers to.
Preet Sangha
+1  A: 

If a resource file is really shared between projects, you should put it in a shared project.

Solution 'Sample'
   Project Sample.Data
   Project Sample.Business
   Project Sample.UI
   Project Sample.Resource   //shared resources are put in a shared project  
Danny Chen
Project has the same structure what you say. The problem is that I can't see `Project Sample.Resource.ImageResource.resx` in `Project Sample.UI` in the designer. I must go to the `myForm.designer.cs` and manually types `button.Image = Sample.Resource.ImageResource.SomeImage`.. And later when VS reconstruct `myForm.designer.cs` line where I types an image for a button will be `button.Image = ( (System.Drawing.Image)( resources.GetObject( "SomeImage.Image" ) ) );` And VS automatically insert (copying) from ImageResource.resx file SomeImage into resource file for specific form.. :(
Yuriy