Domanda

I have a solution which has a WinForm application (Project 1) which makes use of a Class2 from another Class Library project (Project 2). Project 2 makes use of a class3 which is defined in another Class Library project (Project 3).

I know I can override application settings of Project 2 from my Main WinForm application, but, my question is, can I override application settings which were defined in Class Library Project (Project 3) from my main WinForm application (Project 1)

I know it looks like Im making things complicated, but I had to override application settings of Project 3 from my main application.

Can anyone put some light in this direction and suggest how to resolve this?

FYI...

When you add a setting.settings file, it will automatically creates a app.config file and we can configure applicationSettings from Setting.settings UI in VS. Below is the app.config file content from Project3 whose applicationSettings Im interested to override in another WinForm project.

 <?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <configSections>
        <sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
            <section name="Project3.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
        </sectionGroup>
    </configSections>
    <applicationSettings>
        <Project3.Settings>
            <setting name="SettingInProject3" serializeAs="String">
                <value>TempPath</value>
            </setting>
        </Project3.Settings>
    </applicationSettings>
</configuration>

What modifications in app.config file of WinForm application can override the settings defined in Project3 class library.

The hierarchy of references goes something like this. WinForm>Project2DLL>Project3DLL.

Please let me know if further information is needed.

È stato utile?

Soluzione

Open the settings in the source project in visual studio, Ensure the Access modifier (at the top) in the settings viewer in visual studio is set to public. Now these settings will be accessible from your external projects.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top