手动更新app.config是个好主意吗?

时间:2016-04-14 05:46:25

标签: c# .net dll app-config

我正在将C#应用程序更新到.NET 4.0。较旧的应用程序使用多个第三方DLL,需要从版本2509.0.0.0升级到3396.0.0.0

在旧版应用程序中,app.config文件包含以下几种节点:

<configSections>
    <section name="cachingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Caching.Configuration.CacheManagerSettings, Microsoft.Practices.EnterpriseLibrary.Caching, Version=2509.0.0.0, Culture=neutral, PublicKeyToken=ecdd5b3dfcfef3bb" />
</configSections>
.
.
.
<cachingConfiguration defaultCacheManager="Users">
<cacheManagers>
  <add expirationPollFrequencyInSeconds="60" maximumElementsInCacheBeforeScavenging="100000" numberToRemoveWhenScavenging="0" backingStoreName="Isolated Storage" name="SendQueues" />
  <add expirationPollFrequencyInSeconds="60" maximumElementsInCacheBeforeScavenging="1000" numberToRemoveWhenScavenging="10" backingStoreName="Null Storage" name="ServiceUrls" />
  <add expirationPollFrequencyInSeconds="60" maximumElementsInCacheBeforeScavenging="10" numberToRemoveWhenScavenging="1" backingStoreName="Null Storage" name="MonitorData" />
  <add expirationPollFrequencyInSeconds="60" maximumElementsInCacheBeforeScavenging="10" numberToRemoveWhenScavenging="1" backingStoreName="Null Storage" name="Shipments" />
  <add expirationPollFrequencyInSeconds="5" maximumElementsInCacheBeforeScavenging="1000" numberToRemoveWhenScavenging="10" backingStoreName="Tag Collection Storage" name="TagCollections" />
  <add expirationPollFrequencyInSeconds="60" maximumElementsInCacheBeforeScavenging="1000" numberToRemoveWhenScavenging="10" backingStoreName="UserIsolatedStorage" name="Users" />
  <add expirationPollFrequencyInSeconds="60" maximumElementsInCacheBeforeScavenging="1000" numberToRemoveWhenScavenging="10" backingStoreName="WebProxyIsolatedStorage" name="WebProxy" />
  <add expirationPollFrequencyInSeconds="60" maximumElementsInCacheBeforeScavenging="1000" numberToRemoveWhenScavenging="0" backingStoreName="InterfaceMapIsolatedStorage" name="InterfaceMap"/>
  <add expirationPollFrequencyInSeconds="60" maximumElementsInCacheBeforeScavenging="1000" numberToRemoveWhenScavenging="10" backingStoreName="RememberMeIsolatedStorage" name="RememberMe" />
</cacheManagers>
<backingStores>
  <add partitionName="WebProxy" encryptionProviderName="WebProxyEncryption" type="Microsoft.Practices.EnterpriseLibrary.Caching.BackingStoreImplementations.IsolatedStorageBackingStore, Microsoft.Practices.EnterpriseLibrary.Caching, Version=2509.0.0.0, Culture=neutral, PublicKeyToken=ecdd5b3dfcfef3bb" name="WebProxyIsolatedStorage" />
  <add partitionName="SendQueues" encryptionProviderName="SendQueues Encryption" type="Microsoft.Practices.EnterpriseLibrary.Caching.BackingStoreImplementations.IsolatedStorageBackingStore, Microsoft.Practices.EnterpriseLibrary.Caching, Version=2509.0.0.0, Culture=neutral, PublicKeyToken=ecdd5b3dfcfef3bb" name="Isolated Storage" />
  <add partitionName="TagCollections" encryptionProviderName="Tags Cache Encryption" type="Microsoft.Practices.EnterpriseLibrary.Caching.BackingStoreImplementations.IsolatedStorageBackingStore, Microsoft.Practices.EnterpriseLibrary.Caching, Version=2509.0.0.0, Culture=neutral, PublicKeyToken=ecdd5b3dfcfef3bb" name="Tag Collection Storage" />
  <add partitionName="User" encryptionProviderName="Symmetric Storage Encryption" type="Microsoft.Practices.EnterpriseLibrary.Caching.BackingStoreImplementations.IsolatedStorageBackingStore, Microsoft.Practices.EnterpriseLibrary.Caching, Version=2509.0.0.0, Culture=neutral, PublicKeyToken=ecdd5b3dfcfef3bb" name="UserIsolatedStorage" />
  <add encryptionProviderName="" type="Microsoft.Practices.EnterpriseLibrary.Caching.BackingStoreImplementations.NullBackingStore, Microsoft.Practices.EnterpriseLibrary.Caching, Version=2509.0.0.0, Culture=neutral, PublicKeyToken=ecdd5b3dfcfef3bb" name="Null Storage" />
  <add partitionName="RememberMe" encryptionProviderName="Remember me Storage Encryption" type="Microsoft.Practices.EnterpriseLibrary.Caching.BackingStoreImplementations.IsolatedStorageBackingStore, Microsoft.Practices.EnterpriseLibrary.Caching, Version=2509.0.0.0, Culture=neutral, PublicKeyToken=ecdd5b3dfcfef3bb" name="RememberMeIsolatedStorage" />
  <add partitionName="InterfaceMap" encryptionProviderName="InterfaceMap Encryption" type="Microsoft.Practices.EnterpriseLibrary.Caching.BackingStoreImplementations.IsolatedStorageBackingStore, Microsoft.Practices.EnterpriseLibrary.Caching, Version=2509.0.0.0, Culture=neutral, PublicKeyToken=ecdd5b3dfcfef3bb" name="InterfaceMapIsolatedStorage"/>
</backingStores>
<encryptionProviders>
  <add symmetricInstance="DPAPI Symmetric Cryptography Provider" type="Microsoft.Practices.EnterpriseLibrary.Caching.Cryptography.SymmetricStorageEncryptionProvider, Microsoft.Practices.EnterpriseLibrary.Caching.Cryptography, Version=2509.0.0.0, Culture=neutral, PublicKeyToken=ecdd5b3dfcfef3bb" name="WebProxyEncryption" />
  <add symmetricInstance="DPAPI Symmetric Cryptography Provider" type="Microsoft.Practices.EnterpriseLibrary.Caching.Cryptography.SymmetricStorageEncryptionProvider, Microsoft.Practices.EnterpriseLibrary.Caching.Cryptography, Version=2509.0.0.0, Culture=neutral, PublicKeyToken=ecdd5b3dfcfef3bb" name="SendQueues Encryption" />
  <add symmetricInstance="DPAPI Symmetric Cryptography Provider" type="Microsoft.Practices.EnterpriseLibrary.Caching.Cryptography.SymmetricStorageEncryptionProvider, Microsoft.Practices.EnterpriseLibrary.Caching.Cryptography, Version=2509.0.0.0, Culture=neutral, PublicKeyToken=ecdd5b3dfcfef3bb" name="Tags Cache Encryption" />
  <add symmetricInstance="DPAPI Symmetric Cryptography Provider" type="Microsoft.Practices.EnterpriseLibrary.Caching.Cryptography.SymmetricStorageEncryptionProvider, Microsoft.Practices.EnterpriseLibrary.Caching.Cryptography, Version=2509.0.0.0, Culture=neutral, PublicKeyToken=ecdd5b3dfcfef3bb" name="Symmetric Storage Encryption" />
  <add symmetricInstance="DPAPI Symmetric Cryptography Provider" type="Microsoft.Practices.EnterpriseLibrary.Caching.Cryptography.SymmetricStorageEncryptionProvider, Microsoft.Practices.EnterpriseLibrary.Caching.Cryptography, Version=2509.0.0.0, Culture=neutral, PublicKeyToken=ecdd5b3dfcfef3bb" name="Remember me Storage Encryption" />
  <add symmetricInstance="DPAPI Symmetric Cryptography Provider" type="Microsoft.Practices.EnterpriseLibrary.Caching.Cryptography.SymmetricStorageEncryptionProvider, Microsoft.Practices.EnterpriseLibrary.Caching.Cryptography, Version=2509.0.0.0, Culture=neutral, PublicKeyToken=ecdd5b3dfcfef3bb" name="InterfaceMap Encryption"/>
</encryptionProviders>

请注意,引用了许多版本号为2509.0.0.0的DLL。我有每个DLL的版本3396.0.0.0。在app.config文件中修改2509.0.0.03396.0.0.0的所有版本号很有诱惑力,但我认为这不是正确的方法。

该应用程序的旧版本是由其他人开发的。他们是如何生成这样的app.config文件的?如何在app.config文件中为所有这些DLL的版本3396.0.0.0生成必要的节点?

1 个答案:

答案 0 :(得分:0)

我已经差不多2年没有使用.NET了,但是我还记得,有两种方法可以让你的愿望成真:)

  1. 您可以通过更新项目设置重新生成app.config文件,应该检查预构建选项。
  2. 在app.config文件中手动替换,它不会那么有害:)
  3. 祝你好运!