I have multiple projects that are accessing the same settings (they were a single project, but I'm re-factoring). What I would like to do is the equivalent of:
"Add Existing Item" -> "Add Link"
The projects are a mixtutre of both C# and VB. When I try to do add as link, it does bring the settings file in, but it doesn't recognise it. I actually get the error when trying to load the settings:
Error HRESULT E_FAIL has been returned from a call to a COM component.
Is there a way to tell the project to use a specific settings file (either inside or outside the IDE)?
Creating a Shared Project To create a new Shared Project, navigate to File > New > Project. In Visual Studio 2019, enter shared in the search box on the Create a new project page. Select the Shared Project template and then select Next.
A project is contained within a solution. Despite its name, a solution isn't an "answer". It's simply a container for one or more related projects, along with build information, Visual Studio window settings, and any miscellaneous files that aren't associated with a particular project.
Solutions are the containers for all your work in VS.NET. A solution contains a project for each build output. (For example, if you want to build a DLL, an EXE, and an MSI Installer file, your solution will contain three projects.) Projects themselves contain source files.
A solution is simply a container Visual Studio uses to organize one or more related projects. When you open a solution, Visual Studio automatically loads all the projects that the solution contains.
I usually put these things in a common library. When sharing settings, you probably share more than just that, so combine it then. When marking the settings as public instead of internal, you can access them across the other projects.
For future reference:
The solution was to add the Settings file 'as link' to the project, right click and hit 'Run Custom Tool' where the Custom Tool property of the Settings file is 'SettingsSingleFileGenerator'.
Note that this solution is not favored, since it depends on manually updating the settings designer file by performing the above actions.
Taken from MSDN: Add Multiple Settings
"In Solution Explorer, drag the new Settings file into the Properties folder. This allows your new settings to be available in code.
Add and use settings in this file as you would any other settings file. You can access this group of settings via the Properties.Settings object."
I have done this,and it works for me in my C#/VB mixed projects. Hope this helps
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With