【发布时间】:2016-08-05 12:18:25
【问题描述】:
我正在将 C# 应用程序更新到 .NET 4.0。较旧的应用程序使用了多个第三方 DLL,这些 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.0 修改为 3396.0.0.0 很诱人,但我认为这不是正确的做法。
该应用程序的旧版本是由其他人开发的。他们是如何生成这样一个 app.config 文件的?如何在 app.config 文件中为所有这些 DLL 的版本 3396.0.0.0 生成必要的节点?
【问题讨论】:
-
对于你的情况,这似乎不是一个好主意——除非你完全明白你在做什么——一个字符错误可能会导致灾难......
-
@Ian:我同意。但是我能做什么?这种情况下最好的方法是什么?
-
新 dll 版本的公共令牌是否也发生了变化?
-
@Ian:我刚刚检查了一个公钥。它没有改变。不确定其他人。我有所有较新 DLL 的 .manifest 文件。
-
好的,在这种情况下,您可能只能安全地更改版本......在这种情况下我会怎么做?好吧,老实说,我从来没有这样做过...但是理论上,您可以让程序使用 XmlDocument 阅读器,然后获取每个 XmlElement,然后检查公共令牌是否相同,替换版本。如果没有,请不要理会它。无论如何,但不要忘记制作您的
app.config的原始副本。如果失败,则可以取回原来的config文件。您也可以尝试手动更改它。但无论哪种情况,您似乎都处于非常紧张的状态......
标签: c# .net dll app-config