无法加载文件或程序集'System.ServiceModel.Web,Version = 4.0.0.0'

时间:2014-03-12 12:16:10

标签: c# visual-studio-2013 wcf-data-services

Could not load file or assembly 'System.ServiceModel.Web, Version=4.0.0.0' or one of its dependencies. The system cannot find the file specified.

我是visual studio 2013的新用户,我正在尝试wcf data service .edmx 但由于上述错误,我无法成为wcf data service

Visual Studio 2013中的Myservice.svc文件

<%@ ServiceHost Language="C#" Factory="System.ServiceModel.Activation.WebServiceHostFactory, System.ServiceModel.Web, Version=4.0.0.0" Service="_4669.MyService" %>

Visual Studio 2010中的Myservice.svc文件

这个工作正常。

<%@ ServiceHost Language="C#" Factory="System.Data.Services.DataServiceHostFactory, System.Data.Services, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" Service="LoanCalculatorService.srvcLoanCalculator" %>

的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=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
  </configSections>
  <system.web>
    <compilation debug="true" targetFramework="4.5">
      <assemblies>
        <add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
        <add assembly="System.Security, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
        <add assembly="System.Data.Entity.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
      </assemblies>
      <buildProviders>
        <add extension=".edmx" type="System.Data.Entity.Design.AspNet.EntityDesignerBuildProvider" />
      </buildProviders>
    </compilation>
    <httpRuntime targetFramework="4.5" />
  </system.web>
  <system.serviceModel>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
  </system.serviceModel>
  <connectionStrings>
    <add name="SupportDBEntities" connectionString="metadata=res://*/App_Code.Model.csdl|res://*/App_Code.Model.ssdl|res://*/App_Code.Model.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=GOVINDA;initial catalog=SupportTicket;persist security info=True;user id=sa;password=sa_12345;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />
  </connectionStrings>
  <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
      <parameters>
        <parameter value="v11.0" />
      </parameters>
    </defaultConnectionFactory>
  </entityFramework>
</configuration>

注意: -

在我的情况下,当我在wcf data servicevisual studio 2010然后它正在工作时,当我在visual studio 2013中进行操作时,它在我的情况下不起作用。

如果有人对此有所了解,请帮助我。

提前致谢!..

2 个答案:

答案 0 :(得分:0)

尝试将此添加到您的程序集列表中:

<add assembly="System.ServiceModel.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />

此外,如果您没有.NET 4.0,请在此处获取:http://www.microsoft.com/en-US/download/details.aspx?id=17718

答案 1 :(得分:0)

我遇到以下情况: IIS 2 Web应用程序中的Windows Server 2012 R2主机:一个针对.NET 3.5编译另一个 - 针对.NET 4.5.1。两者都在Intergrated管道中运行 服务器已安装.NET 3.5 / 4.0 / 4.5 / 4.5.1及最新更新。 在.NET 3.5上的应用程序中遇到了问题。 修复是用

更新web.config转换
<system.webServer>  
    <handlers>
  <remove name="svc-Integrated-4.0" xdt:Transform="Insert" />
</handlers>             
</system.webServer>  

据我所知,System.ServiceModel.Web,Version = 4.0.0.0无法加载到针对ASP.NET 2.0运行的应用程序池中(对于针对.NET 3.5编译的应用程序),而svc-Integrated-4.0处理程序尝试加载它。