Paul Michaels
Paul Michaels

Reputation: 16705

Sharing settings file between projects in VS2013

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)?

Upvotes: 5

Views: 2668

Answers (2)

Patrick Hofman
Patrick Hofman

Reputation: 157146

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.

Upvotes: 4

PeonProgrammer
PeonProgrammer

Reputation: 1535

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

Upvotes: 1

Related Questions