2016-09-01 5 views
0

iisでホストされているWCFをビルドしようとしましたが、厄介な問題があります。WCF:ファイルまたはアセンブリ 'EntityFramework'またはその依存関係の1つを読み込めませんでした

クライアントコンソールアプリケーションを実行してサーバーに接続すると、「ファイルまたはアセンブリ 'EntityFramework、Version = 6.0.0.0、Culture = neutral、PublicKeyToken = b77a5c561934e089」またはその依存関係の1つを読み込めませんでした。 "

私はサービスとクライアントに3つのナゲットパッケージをインストールしています。 Entityframework 6.0.0.0、MySql.data 6.9.9およびMySql.Data.Entity 6.9.9。

MySql.Data.Entityでは、MySql.Dataが6.8.7より高く、EntityFrameworkが6.0.0.0以上である必要があります。私は私のサービスapp.configファイルのどこでもEF 6.0.0.0を参照していると確信していますが、まだエラーが出ます。

誰かがこれを引き起こす可能性があることを知っていますか?エンティティフレームワーク6.1.3が自分のコンピュータにインストールされているだけですが、それは問題になる可能性がありますか?

私のプロジェクトにはちょっと残っています。誰かが時間を取ってくれたら本当にいいと思います!

クライアントプロジェクト

App.configファイル:

<?xml version="1.0" encoding="utf-8"?> 
<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=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" /> 
    </configSections> 
    <startup> 
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" /> 
    </startup> 
    <system.serviceModel> 
    <bindings> 
     <basicHttpBinding> 
     <binding name="BasicHttpBinding_IWCFProductService" /> 
     </basicHttpBinding> 
    </bindings> 
    <client> 
     <endpoint address="http://localhost:50710/ProductService" binding="basicHttpBinding" bindingConfiguration="" contract="ProductInterfaces.IWCFProductService" name="ProductServiceEndpoint" kind="" endpointConfiguration="" /> 
     <endpoint address="http://erihy283-pc/ProductService/Service.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IWCFProductService" contract="ProductService.IWCFProductService" name="BasicHttpBinding_IWCFProductService" /> 
    </client> 
    </system.serviceModel> 
    <entityFramework> 
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework"> 
     <parameters> 
     <parameter value="v13.0" /> 
     </parameters> 
    </defaultConnectionFactory> 
    <providers> 
     <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" /> 
    <provider invariantName="MySql.Data.MySqlClient" type="MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.Entity.EF6, Version=6.9.9.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d"></provider></providers> 
    </entityFramework> 
<system.data> 
    <DbProviderFactories> 
     <remove invariant="MySql.Data.MySqlClient" /> 
     <add name="MySQL Data Provider" invariant="MySql.Data.MySqlClient" description=".Net Framework Data Provider for MySQL" type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data, Version=6.9.9.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" /> 
    </DbProviderFactories> 
    </system.data></configuration> 

サービスプロジェクト

Packages.config

<?xml version="1.0" encoding="utf-8"?> 
<packages> 
    <package id="EntityFramework" version="6.0.0" targetFramework="net452" /> 
    <package id="MySql.Data" version="6.9.9" targetFramework="net452" /> 
    <package id="MySql.Data.Entity" version="6.9.9" targetFramework="net452" /> 
</packages> 

App.configを

<?xml version="1.0" encoding="utf-8"?> 
<configuration> 
    <configSections> 
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" /> 
    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 --> 
    </configSections> 
    <startup> 
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" /> 
    </startup> 

    <connectionStrings> 
    <add name="adventureworksEntities" connectionString="metadata=res://*/Database.csdl|res://*/Database.ssdl|res://*/Database.msl;provider=MySql.Data.MySqlClient;provider connection string=&quot;server=localhost;user id=root;password=root;database=adventureworks&quot;" providerName="System.Data.EntityClient" /> 
    </connectionStrings> 

    <entityFramework> 
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework"> 
     <parameters> 
     <parameter value="mssqllocaldb" /> 
     </parameters> 
    </defaultConnectionFactory> 
    <providers> 
     <provider invariantName="MySql.Data.MySqlClient" type="MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.Entity.EF6, Version=6.9.9.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d"></provider> 
     <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" /> 
    </providers> 
    </entityFramework> 

    <system.serviceModel> 
    <services> 
     <service name="WCFProductService" behaviorConfiguration="mexBehaviour"> 

     <endpoint address="ProductService" 
       binding="basicHttpBinding" 
       bindingConfiguration="" 
       name="ProductServiceEndpoint" 
       contract="ProductService.IWCFProductService" 
       behaviorConfiguration="webHttp" /> 

     <endpoint contract="IMetadataExchange" 
       binding="mexHttpBinding" 
       address="ProductService" /> 

     <host> 
      <baseAddresses> 
      <add baseAddress="http://localhost:50710" /> 
      </baseAddresses> 
     </host> 
     </service> 
    </services> 
    </system.serviceModel> 

    <system.data> 
    <DbProviderFactories> 
     <remove invariant="MySql.Data.MySqlClient" /> 
     <add name="MySQL Data Provider" invariant="MySql.Data.MySqlClient" description=".Net Framework Data Provider for MySQL" type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data, Version=6.9.9.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" /> 
    </DbProviderFactories> 
    </system.data> 

    <runtime> 

    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> 
     <dependentAssembly> 
     <assemblyIdentity name="MySql.Data" publicKeyToken="c5687fc88969c44d" culture="neutral" /> 
     <bindingRedirect oldVersion="0.0.0.0-6.9.9.0" newVersion="6.9.9.0" /> 
     </dependentAssembly> 

     <dependentAssembly> 
     <assemblyIdentity name="EntityFramework" publicKeyToken="b77a5c561934e089" culture="neutral" /> 
     <bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" /> 
     </dependentAssembly> 
    </assemblyBinding> 

    </runtime> 

</configuration> 

ホストプロジェクト

web.configファイル

<?xml version="1.0" encoding="UTF-8"?> 
<configuration> 

    <system.diagnostics> 
    <trace autoflush="true" /> 
    <sources> 
     <source name="System.ServiceModel" 
      switchValue="Information, ActivityTracing" 
      propagateActivity="true"> 
     <listeners> 
      <add name="sdt" 
      type="System.Diagnostics.XmlWriterTraceListener" 
      initializeData= "SdrConfigExample.e2e" /> 
     </listeners> 
     </source> 
    </sources> 
    </system.diagnostics> 

    <system.serviceModel> 

    <services> 
     <service name="WCFProductService" > 

     <endpoint address="ProductService" 
       binding="basicHttpBinding" 
       bindingConfiguration="" 
       name="ProductServiceEndpoint" 
       contract="ProductService.IWCFProductService" 
       behaviorConfiguration="webHttp"/> 

     <endpoint address="http://localhost:50710/svc/mex" 
       binding="mexHttpBinding" 
       bindingConfiguration="" 
       contract="IMetadataExchange"/> 

     <host> 
      <baseAddresses> 
      <add baseAddress="http://localhost:50710" /> 
      </baseAddresses> 
     </host> 

     </service> 
    </services> 


    <behaviors> 
     <serviceBehaviors> 
     <behavior> 
      <serviceMetadata httpGetEnabled="true"/> 
      <serviceDebug includeExceptionDetailInFaults="true"/> 
     </behavior> 
     </serviceBehaviors> 

     <endpointBehaviors> 
     <behavior name="webHttp"> 
      <webHttp/> 
     </behavior> 
     </endpointBehaviors> 
    </behaviors> 

    </system.serviceModel> 

</configuration> 

packages.config

<?xml version="1.0" encoding="utf-8"?> 
<packages> 
    <package id="EntityFramework" version="6.0.0" targetFramework="net452" /> 
    <package id="MySql.Data" version="6.9.9" targetFramework="net452" /> 
    <package id="MySql.Data.Entity" version="6.9.9" targetFramework="net452" /> 
</packages> 

私は、IISで設定したアプリケーションプールのASP.NET v4.0のを持っています!

+0

私はそれがあなたのApp.ConfigのEntityFrameworkのタグと関係があると確信しています... https://msdn.microsoft.com/en-us/library/twy1dw1e(v=vs。 110).aspxまさにそれを修正するために何をすべきか...私はceratinではありません。 –

答えて

0

読み込み中のパッケージが存在しないため、通常、エラーメッセージが表示されます。これをチェックする1つの方法は、あなたが見つけられればあなたの "packages"フォルダを探して、使用されている各パッケージ用のフォルダがどこにあるかを調べることです。このフォルダのバージョン番号は、あなたが求めているものと一致することが重要です。 EntityFramework.6.0.0(あなたのpackages.configファイルが要求している)の代わりにEntityFramework.6.1.3がある可能性があります。

Visual Studioでは、パッケージマネージャコンソール(ツール - > NuGetパッケージマネージャ - >パッケージマネージャコンソール)を使用して、コマンドupdate-package EntityFramework -version 6.0.0を使用できます。これはあなたが求めている特定のバージョンへのアップデートを行い、ローカルで見つからない場合はNuGetを使ってパッケージをダウンロードします。

関連する問題