Question

I've currently got a solution where a certain class is used from several C# projects, some Silverlight, some regular. For compatibility reasons I cannot create a single project for these utility classes. At first I solved the problem by making the class library project a silverlight one, so that it could be referenced by all other projects.

However, I ran into another problem that made it impossible to use a Silverlight project as the class library. So I resorted to making two separate class library projects: one Silverlight, one regular. In C++ it's possible to add a project file to two projects, while only having one physical file on disk. I noticed that in C#, it automatically makes a copy when adding the file to a second project. I solved this with a build event that copies the file from the regular library to the Silverlight one when the Silverlight project is built.

This all works, so technically the problem is solved. However, it's gotten too convoluted for my taste. Also, other programmers who are unaware of my solution might start to edit the dependent (Silverlight) file, and get unexpected results.

So my question is, do you know of any good reasons to solve these two issues properly? How would you solve it?

Was it helpful?

Solution

If you need 1 file on disk do not use the standard "Add" when adding the file to your project but click on the arrow next to it in the dialog and select "Add as link", however this does not prevent it from being edited (you'll have to look into other options there, I'm not aware of any)

OTHER TIPS

I think you are talking about linking. Have a look here:

http://support.microsoft.com/kb/306234

Hope this helps.

have the file in one project then in the other projects where you want to have it as well do Add Existing Item, select the file and see the Add button in the dialog has a small arrow, select Add as Link from there and you are set. :)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top