I am trying to re-use a generic database selection form between two projects by pulling the *.cs and *.resx files into another directory and then having both projects use those files.
Unfortunately, having done this, I can't work out how to include this form in both my projects.
If I "Add > Existing Item..." to my project it simply copies the files into my project directory.
I tried hacking the *.csproj file as follows:
Before:
<File
RelPath = "ServerSelectForm.cs"
SubType = "Form"
BuildAction = "Compile"
/>
<File
RelPath = "ServerSelectForm.resx"
DependentUpon = "ServerSelectForm.cs"
BuildAction = "EmbeddedResource"
/>
After:
<File
RelPath = "..\_Common\DatabaseSelectorForm\DatabaseSelectorForm.cs"
SubType = "Form"
BuildAction = "Compile"
/>
<File
RelPath = "..\_Common\DatabaseSelectorForm\DatabaseSelectorForm.resx"
DependentUpon = "..\_Common\DatabaseSelectorForm\DatabaseSelectorForm.cs"
BuildAction = "EmbeddedResource"
/>
If I do that Visual Studio doesn't like that -- it ignores those entries, doesn't load the form, and, upon saving the project, simply strips them out of the new project file!
I strongly suspect that my whole approach to code re-use is a bit "vb6" -- could someone enlighten me to the 'proper' way to do this?
(I was trying to avoid going all-out and compiling the form into a standalone DLL as I think that would be overkill.)
Thanks in advance.