我在我的应用程序项目中编写了一些值(我的解决方案中的WpfApplication1项目),问题是是否有可能在StateModule项目等类库中检索它们。
<?xml version="1.0"?>
<configuration>
<configSections>
<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<section name="WpfApplication1.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"/>
</sectionGroup>
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="WpfApplication1.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
</sectionGroup>
</configSections>
<applicationSettings>
<WpfApplication1.Properties.Settings>
<setting name="a" serializeAs="String">
<value>b</value>
</setting>
</WpfApplication1.Properties.Settings>
</applicationSettings>
<userSettings>
<WpfApplication1.Properties.Settings>
<setting name="b" serializeAs="String">
<value>c</value>
</setting>
</WpfApplication1.Properties.Settings>
</userSettings>
</configuration>
我可以使用以下方法访问WpfApplication1项目中的值:
string myStr = Properties.Settings.Default.a;
由于我已经在WpfApplication1中添加了对项目StateModule的引用,我不能反过来这样做。
谁能告诉我我应该做什么?或者这些设计模式有什么问题吗?