Error thrown by a dependency of object ‘System.Data.SQLite’ 解決辦法

來源:互聯網
上載者:User

項目中用的.net4+mvc3+spring.net1.3.2+nhibernate32+SQLite 1.0.79版本,就目前來說,應該是最新的,

在使用的時候單獨用nh連結sqlite是沒問題的,但是用spring.net配置nhibernate問題就來了,

 

1.3.2的版本就支援SQLite1.0.72的版本,因為我用的是1.0.79的版本,如果寫成System.Date.SQLite,報錯為

注意紅線的報錯,我查看了Spring.net的源碼,裡面是這樣寫的,

 

為什麼他會報這兒的錯呢,因為後面還有句:

<alias name="SQLite-1.0.65" alias="System.Data.SQLite"/>

他把這個直接映射到了1.0.65的版本,而且裡面最高的版本為1.0.72,沒有我想要的1.0.79,解決辦法很簡單,自己再加一個就是了,注意看我第一張圖:

<!--資料庫提供者-->  <db:additionalProviders resource="assembly://Mark/Mark.ConfigFiles/SQLite.xml"/>

這個SQLite.xml就是我自己寫的,其實就是copy他的寫法,我只是不知道那個PublicKeyToken是多少,直接刪除了,一樣的可以用,SQLite.xml裡面的內容是:

<?xml version="1.0" encoding="utf-8" ?><objects xmlns="http://www.springframework.net" xmlns:db="http://www.springframework.net/database">  <object id="SQLite-1.0.79" type="Spring.Data.Common.DbProvider, Spring.Data" singleton="false">    <constructor-arg name="dbMetaData">      <object type="Spring.Data.Common.DbMetadata">        <constructor-arg name="productName" value="SQLite"/>        <constructor-arg name="assemblyName" value="System.Data.SQLite, Version=1.0.79.0, Culture=neutral"/>        <constructor-arg name="connectionType" value="System.Data.SQLite.SQLiteConnection, System.Data.SQLite, Version=1.0.79.0, Culture=neutral"/>        <constructor-arg name="commandType" value="System.Data.SQLite.SQLiteCommand, System.Data.SQLite, Version=1.0.79.0, Culture=neutral"/>        <constructor-arg name="parameterType" value="System.Data.SQLite.SQLiteParameter, System.Data.SQLite, Version=1.0.79.0, Culture=neutral"/>        <constructor-arg name="dataAdapterType" value="System.Data.SQLite.SQLiteDataAdapter , System.Data.SQLite, Version=1.0.79.0, Culture=neutral"/>        <constructor-arg name="commandBuilderType" value="System.Data.SQLite.SQLiteCommandBuilder, System.Data.SQLite, Version=1.0.79.0, Culture=neutral"/>        <constructor-arg name="commandBuilderDeriveParametersMethod" value="not supported"/>        <constructor-arg name="parameterDbType" value="System.Data.SQLite.TypeAffinity, System.Data.SQLite, Version=1.0.79.0, Culture=neutral"/>        <constructor-arg name="parameterDbTypeProperty" value="DbType"/>        <constructor-arg name="parameterIsNullableProperty" value="IsNullable"/>        <constructor-arg name="parameterNamePrefix" value=":"/>        <constructor-arg name="exceptionType" value="System.Data.SQLite.SQLiteException, System.Data.SQLite, Version=1.0.79.0, Culture=neutral"/>        <constructor-arg name="useParameterNamePrefixInParameterCollection" value="true"/>        <constructor-arg name="useParameterPrefixInSql" value="true"/>        <constructor-arg name="bindByName" value="true"/>        <!-- this is only true for .net 1.1 kept it here just in case we want to revert back to this strategy for             obtaining error codes-->        <constructor-arg name="errorCodeExceptionExpression" value="ErrorCode.ToString('D')"/>        <property name="ErrorCodes.badSqlGrammarCodes">          <value></value>        </property>        <property name="ErrorCodes.DataAccessResourceFailureCodes">          <value>1</value>        </property>        <property name="ErrorCodes.DataIntegrityViolationCodes">          <value></value>        </property>        <property name="ErrorCodes.CannotAcquireLockCodes">          <value>15</value>        </property>        <property name="ErrorCodes.DeadlockLoserCodes">          <value>5,6</value>        </property>      </object>    </constructor-arg>  </object></objects>

然後寫:

<db:provider id="DbProvider" provider="SQLite-1.0.79" connectionString="Data Source=|DataDirectory|xxxx.db;Version=3;FailIfMissing=False;"/>

再運行,不報錯了

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.