无法加载文件或程序集“System.ServiceModel.Web,版本 = 4.0.0.0" [英] Could not load file or assembly 'System.ServiceModel.Web, Version=4.0.0.0'

查看:50
本文介绍了无法加载文件或程序集“System.ServiceModel.Web,版本 = 4.0.0.0"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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 的新手,我正在尝试使用 .edmx 制作 wcf 数据服务但由于上述错误,我无法创建我的 wcf 数据服务.

I am new with visual studio 2013 and I am trying to make wcf data service with .edmx but I could not made my wcf data service due to above error.

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>

注意:-

在我的情况下,当我在 visual studio 2010 中制作 wcf data service 然后它工作,当我在 visual studio 2013 中制作时它在我的情况下不起作用.

In my case when I make wcf data service in visual studio 2010 then it working and when i make in visual studio 2013 then it is not working in my case.

如果有人对此有任何想法,请帮助我.

if someone have any idea about it then please help me.

提前致谢!..

推荐答案

我发现在新建的 Windows 2012R2 服务器上,上述解决方案都不适合我.我安装了 3.5 和 4.5 作为框架和 ASP.NET 功能.将我的应用程序重新编译为 Full 而不是 Client 没有任何区别.然后我尝试浏览到默认网站,当出现同样的错误时,我开始认为一些根本性的问题是错误的.

I found that none of the above solutions worked for me on a newly built Windows 2012R2 server. I had 3.5 and 4.5 installed as both Frameworks and ASP.NET Features. Recompiling my application as Full rather than Client made no difference. Then I tried browsing to the Default Web Site and when that gave the same error I started to think something fundamental was wrong.

我找到的解决方案是在两者中编辑 web.configC:\Windows\Microsoft.NET\Framework\v4.0.30319\Config和C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Config

The solution I found was to edit the web.config in both C:\Windows\Microsoft.NET\Framework\v4.0.30319\Config and C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Config

(假设您可以使用 32 位或 64 位应用程序池)

(assuming that you may use either 32 or 64 bit application pools)

并简单地注释掉对 System.ServiceModel.Web 的引用即:

and simply comment out the reference to System.ServiceModel.Web ie:

改变

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

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

然后默认网站正确加载,我自己的 ASP.NET 系统也是如此

The Default Web Site then loaded correctly and so did my own ASP.NET system

这篇关于无法加载文件或程序集“System.ServiceModel.Web,版本 = 4.0.0.0"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆