1

「登録された .Net Framework Data Provider の検索または読み込みに失敗しました。」の実行中にサーバーでエラーが発生しました。ASP.NET MVC 4 + Entity Frameworkに含まれるSql Compact 4データベースがあり、godaddyサーバーにアップロードしています... web.configは次のとおりです

Web.Config

<?xml version="1.0" encoding="utf-8"?>
<!--
  For more information on how to configure your ASP.NET application, please visit
  http://go.microsoft.com/fwlink/?LinkId=169433
  -->
<configuration>
  <configSections>
    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=4.4.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
  </configSections>
  <connectionStrings>
    <add name="EShip" connectionString="Data Source=|DataDirectory|\EShip.sdf" providerName="System.Data.SqlServerCe.4.0" />
  </connectionStrings>
  <appSettings>
    <add key="webpages:Version" value="2.0.0.0" />
    <add key="webpages:Enabled" value="false" />
    <add key="PreserveLoginUrl" value="true" />
    <add key="ClientValidationEnabled" value="true" />
    <add key="UnobtrusiveJavaScriptEnabled" value="true" />
  </appSettings>
  <system.web>
    <compilation debug="true" targetFramework="4.0" />
    <customErrors mode="Off"/>
    <pages>
      <namespaces>
        <add namespace="System.Web.Helpers" />
        <add namespace="System.Web.Mvc" />
        <add namespace="System.Web.Mvc.Ajax" />
        <add namespace="System.Web.Mvc.Html" />
        <add namespace="System.Web.Optimization" />
        <add namespace="System.Web.Routing" />
        <add namespace="System.Web.WebPages" />
      </namespaces>
    </pages>
  </system.web>
  <system.webServer>
    <validation validateIntegratedModeConfiguration="false" />
    <modules runAllManagedModulesForAllRequests="true" />
    <handlers>
      <remove name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" />
      <remove name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" />
      <remove name="ExtensionlessUrlHandler-Integrated-4.0" />
      <add name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness32" responseBufferLimit="0" />
      <add name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness64" responseBufferLimit="0" />
      <add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
    </handlers>
  </system.webServer>
  <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
      <parameters>
        <parameter value="v11.0" />
      </parameters>
    </defaultConnectionFactory>
  </entityFramework>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-1.3.0.0" newVersion="1.3.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
  <system.data>
    <DbProviderFactories>
      <remove invariant="System.Data.SqlServerCe.4.0"/>
      <add name="Microsoft SQL Server Compact Data Provider 4.0"
           invariant="System.Data.SqlServerCe.4.0"
           description=".NET Framework Data Provider for Microsoft SQL Server Compact"
           type="System.Data.SqlServerCe.SqlCeProviderFactory, System.Data.SqlServerCe, Version=4.0.0.1, 
             Culture=neutral, 
             PublicKeyToken=89845dcd8080cc91"/>
    </DbProviderFactories>
  </system.data>
</configuration>

[/xml]

4

2 に答える 2

1

OPのコメントを使用して、もう少し冗長なバージョンがあります。

手にナゲットがあれば、コマンドを実行できます

install EntityFramework.SqlServerCompact

SqlServerCompact をダウンロードするには

  • Microsoft.SqlServer.コンパクト
  • SqlServerCompact
  • EntityFramework
  • EntityFramework.SqlServerCompacy

したがって、この問題が発生する可能性のある原因は、インストールに SqlServerCompact がないことであると推測できます。

于 2013-09-11T17:33:37.437 に答える
0

簡単なテストアプリでも同様の問題がありました。

Install-PackageEntityFramework.SqlServerCompactは、SqlServer Compact dll をアプリの「packages」ディレクトリに追加することで、「登録された .Net Framework Data Provider の検索または読み込みに失敗しました」というメッセージを取り除きました。packages.config に以下を追加しました。

<?xml version="1.0" encoding="utf-8"?>
<packages>
  <package id="EntityFramework" version="5.0.0" targetFramework="net40-Client" />
  <package id="EntityFramework.SqlServerCompact" version="4.3.6" targetFramework="net40-Client" />
  <package id="Microsoft.SqlServer.Compact" version="4.0.8876.1" targetFramework="net40-Client" />
  <package id="SqlServerCompact" version="4.0.8854.1" targetFramework="net40-Client" />
</packages>

また、アプリの参照にSystem.Data.SqlServerCeとを追加しました。System.DataSqlServerCe.Entity

その後、このような例外が発生しました。

System.IO.FileLoadException was unhandled
  Message=Could not load file or assembly 'System.Data.SqlServerCe, Version=4.0.0.1, Culture=neutral, PublicKeyToken=89845dcd8080cc91' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
  Source=mscorlib
  FileName=System.Data.SqlServerCe, Version=4.0.0.1, Culture=neutral, PublicKeyToken=89845dcd8080cc91
  FusionLog==== Pre-bind state information ===
LOG: User = mulcahy\mulcahy_admin
LOG: DisplayName = System.Data.SqlServerCe, Version=4.0.0.1, Culture=neutral, PublicKeyToken=89845dcd8080cc91
 (Fully-specified)
LOG: Appbase = file:///C:/Users/mulcahy_admin/Dropbox/projects/ons/CSLCE4CL/CSLCE4CL/bin/Debug/
LOG: Initial PrivatePath = NULL
Calling assembly : System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Users\mulcahy_admin\Dropbox\projects\ons\CSLCE4CL\CSLCE4CL\bin\Debug\CSLCE4CL.vshost.exe.Config
LOG: Using host configuration file: 
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Redirect found in application configuration file: 4.0.0.1 redirected to 4.0.0.1.
LOG: Post-policy reference: System.Data.SqlServerCe, Version=4.0.0.1, Culture=neutral, PublicKeyToken=89845dcd8080cc91
LOG: Attempting download of new URL file:///C:/Users/mulcahy_admin/Dropbox/projects/ons/CSLCE4CL/CSLCE4CL/bin/Debug/System.Data.SqlServerCe.DLL.
WRN: Comparing the assembly name resulted in the mismatch: Revision Number
ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.

これは、アプリが SqlServerCE v4.0.0.1 を使用するように構成されていることを示唆しているようですが、v4.0.0.0 が見つかります

そこで、Eriks の提案を使用して、DbProviderFactories エントリを v4.0.0.0 に変更し、v4.0.0.1 の新しいバージョンを参照する bindingRedirect エントリを削除しました。

これはうまくいくようです。この道をたどるすべての人に役立つことを願っています...

その間、私は少し困惑しています。

  1. System.Data.SqlServerCe.dllバージョン 4.0.8876.1 である理由 - これが実際に v4.0.0.0 であることをどうやって知ることができますか
  2. v4.0.0.1 のリファレンスはどこから来たのですか? このバージョンは自分のマシンのどこかになければなりませんか?
于 2013-09-18T11:00:54.763 に答える