0

最近、ウェブサイトを1.1から2.0にアップグレードすることを決定しました。Visual Studio 2010を使用してアップグレードしましたが、アップグレードは正常に機能しました。

このWebサイトはEnterpriseLibrary2005を使用しており、それを機能させるのに非常に時間がかかっています。APIに大きな違いがあるため、EnterpriseLibrary2006をアップグレードしないことをお勧めします。

エンタープライズライブラリを機能させるために最初に行ったのは、これを\ Framework \ v2.0.50727\Machine.Configに追加したことです。

   <?xml version="1.0" encoding="UTF-8"?>
    <configuration>
        <configSections>
            <section name="enterpriselibrary.configurationSettings" type="System.Configuration.IgnoreSectionHandler, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
        </configSections>
        <enterpriselibrary.configurationSettings xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" applicationName="X" xmlns="http://www.microsoft.com/practices/enterpriselibrary/08-31-2004/configuration">
            <configurationSections>
                <configurationSection xsi:type="ReadOnlyConfigurationSectionData" name="dataConfiguration" encrypt="false">
                    <storageProvider xsi:type="RegistryStorageProviderData" name="Registry Storage Provider" registryRoot="LocalMachine" registrySubKey="SOFTWARE\X" />
                    <dataTransformer xsi:type="XmlSerializerTransformerData" name="Xml Serializer Transformer">
                        <includeTypes />
                    </dataTransformer>
                </configurationSection>
                <configurationSection xsi:type="ReadOnlyConfigurationSectionData" name="securityCryptographyConfiguration" encrypt="false">
                    <storageProvider xsi:type="RegistryStorageProviderData" name="Registry Storage Provider" registryRoot="LocalMachine" registrySubKey="SOFTWARE\X" />
                    <dataTransformer xsi:type="XmlSerializerTransformerData" name="Xml Serializer Transformer">
                        <includeTypes />
                    </dataTransformer>
                </configurationSection>
            </configurationSections>
            <keyAlgorithmStorageProvider xsi:nil="true" />
            <includeTypes />
        </enterpriselibrary.configurationSettings>
    </configuration>

しかし、私がこの関数を呼び出すたびに

Cryptographer.CompareHash( "X", X, X ) 

このエラーが発生します

System.InvalidCastException was unhandled
  Message=Specified cast is not valid.
  Source=Microsoft.Practices.EnterpriseLibrary.Configuration
  StackTrace:
       at Microsoft.Practices.EnterpriseLibrary.Configuration.Storage.ConfigurationChangedRegistryWatcher.Poller()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.runTryCode(Object userData)
       at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
       at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException: 

この関数を呼び出そうとすると、同じエラーが発生します

DBCommandWrapper l_sqlWrapper = _db.GetStoredProcCommandWrapper("x");
l_sqlWrapper.AddInParameter("@x", DbType.Int32, "X");

これは1.1で正常に機能し、渡したすべての値がnullではなく、正当な値を持っていることを確認したためです。誰かがなぜ手がかりを持っているでしょうか?

4

2 に答える 2

1

Entlib 1.1は、.NET2.0では明示的にサポートされていません。実際には、それはもうまったくサポートされていませんが、それは別の質問です。

.NET1.1と.NET2.0の間には多くの違いがあります。大きく変わったものの1つは、構成システムです。

entlib1.1をVS2005でコンパイルして2.0をターゲットにしたバージョンを取得することができましたが、それはかなり前のことであり、簡単なテストしか行いませんでした。

基本的に、ここでの標準的な答えは「entlib2に切り替える」です。はい、多くの変更がありましたが、1.1のものはもう機能しません。

于 2012-05-29T23:49:21.427 に答える
0

問題が修正されました。

エンタープライズライブラリをダウンロードし、.Net2.0でVS2010に変換することで問題を修正しました。次に、#defineVS2003で#defineVS2005B2を検索/置換しました。

次に、プロジェクトへの参照を追加し、すべてが機能しました。

于 2012-05-30T14:08:19.210 に答える