1
我的項目由一個Web服務(WCF)和一個在其他項目中使用公共庫的控制檯應用程序組成。 這個庫有ApplicationSettings。 隨着控制檯應用程序,我只需要設置:具有WCF和控制檯應用程序的DLL的應用程序設置
<?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="MyProject.Library.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</sectionGroup>
</configSections>
[...]
<applicationSettings>
<MyProject.Library.Properties.Settings>
<setting name="EnvironmentMask" serializeAs="String">
<value>RCT_</value>
</setting>
</MyProject.Library.Properties.Settings>
</applicationSettings>
[...]
</configuration>
我試圖做的同一側的Web.config
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<sectionGroup name="MyCompany.ConfigurationGroup">
<section name="SignedFileConfiguration" type="MyCompany.Web.SecureFileProxy.SignedFileConfigurationHandler, Net.MyCompany.Web" />
</sectionGroup>
<sectionGroup name="applicationSettings">
<section name="MyProject.Library.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</sectionGroup>
</configSections>
[...]
<MyCompany.ConfigurationGroup>
<SignedFileConfiguration Secret="SecretKey!" PatternOfGeneratedUrl="http://www.myCompany.net/cgi/getFile.aspx?volume={0}&path={1}&token={2}&name={3}" ConfiguratorType="MyCompany.Web.SecureFileProxy.SignedFileConfiguration, Net.MyCompany.Web">
<Volumes>
<add Name="fallow" PhysicalPath="" />
</Volumes>
</SignedFileConfiguration>
</MyCompany.ConfigurationGroup>
<applicationSettings>
<MyProject.Library.Properties.Settings>
<setting name="EnvironmentMask" serializeAs="String">
<value>DEV_</value>
</setting>
</MyProject.Library.Properties.Settings>
</applicationSettings>
[...]
</configuration>
Web服務的執行過程中,我得到一個異常:系統。 Configuration.SettingsPropertyNotFoundException和對象MyProject.Library.Properties.Settings爲空
談論這個問題的唯一網站是https://littletalk.wordpress.com/2008/05/07/use-applicationsettings-in-web-application/但它對我來說還不夠。
我希望你能幫助我。 感謝您的關注 Regards