I have the following project structure:
Library1 <--[project reference]-- Library2 <--[ref]-- Executable
-------- --------
Add Library1 reference to the Executable project.
One variation on Brenda's answer would be to add the Library1's content file(s) as Link(s) in the Executable project. You'd still have the entries in the project but you wouldn't need manage multiple copies of each file.
Could be that you reference Library1 only from an XAML file in that case Visual Studio dont recognice the usage. Add a reference in code as well e.g. by applying the name attribute
EDIT:
You can put all content in a separate project, set all its entries to "content" and "copy always" and reference that project from External and Executable
-
IMO you're looking for embedded resource, not for content files.
When you compile Library 1 the content files are placed in its bin folder. When Library 2 is compiled the compiler recognizes referenced code and includes it (Library 1.dll) but the content files aren't recognized since they aren't mentioned anywhere in Library 2. The same goes when linking Library 2 to the executable.
If your content files are relatively small (icons, templates etc) and you don't envision need to edit them if you were to lose the source code then you can embed them as resources and provide a public method to return the contents, such as:
public static Stream GetResourceContent(string rName){
string resName = System.Reflection.Assembly
.GetExecutingAssembly().GetManifestResourceNames()
.FirstOrDefault(rn => rn.EndsWith("."+rName));
if(resName!=null)
return System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream(resName);
else
return null;
}
If your content is bound to change, such as templates etc, then consider including a copy with the executable project
Another option would be to embed ContentFile as a resource inside the Library1 assembly and extract it using Assembly.GetManifestResource().
See these links for more info:
http://www.attilan.com/2006/08/accessing-embedded-resources-using.html
http://blogs.msdn.com/b/alexdan/archive/2007/12/19/loading-embedded-resources-in-c-using-getmanifestresourcestream.aspx