我想弄清楚如何配置企業庫5.0數據訪問應用程序塊。 當運行單元測試我,我得到以下錯誤:配置企業庫5.0數據訪問應用程序塊
var db = DatabaseFactory.CreateDatabase("PokerAdviserProvider");
的App.config:
<configuration>
<configSections>
<section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" />
</configSections>
<dataConfiguration defaultDatabase="PokerAdviserProvider" />
<connectionStrings>
<add name="PokerAdviserProvider" connectionString="server=(localhost);Initial Catalog=PokerAdviser;uid=abc;pwd=xyz"
providerName="System.Data.SqlClient" />
</connectionStrings>
</configuration>
我一直
Microsoft.Practices.ServiceLocation.ActivationException was caught
Message=Activation error occured while trying to get instance of type Database, key "PokerAdviserProvider"
InnerException: Microsoft.Practices.Unity.ResolutionFailedException
Message=Resolution of the dependency failed, type = "Microsoft.Practices.EnterpriseLibrary.Data.Database", name = "PokerAdviserProvider".
Exception occurred while: while resolving.
Exception is: InvalidOperationException - The type Database cannot be constructed. You must configure the container to supply this value.
的代碼,我得到這個線google搜索了一下週圍,發現了一些答案,這些設置也應該把我的單元測試項目的App.config中,但是這並沒有有所作爲。
我有點卡在這裏,所以任何幫助,高度讚賞。
編輯:
我引用正確的DLL的(那些從程序文件,而不是從源代碼),所以這不是problemneither。