Could not load file or assembly 'System.ServiceModel.Web, Version=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.

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.

Myservice.svc File in visual studio 2013

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

Myservice.svc File in visual studio 2010

This one is working fine.

<%@ 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>

Note:-

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.

Thanks in advance !..

Answers


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.

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

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

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

Change

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

to

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

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


Try adding this to your assembly list:

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

Also if you don't have .NET 4.0, get it here: http://www.microsoft.com/en-US/download/details.aspx?id=17718


I encountered such a situation in following circumstances: Windows Server 2012 R2 hosts in IIS 2 web applications: one compiles against .NET 3.5 another - to .NET 4.5.1. Both are running in Intergrated pipeline Server have installed .NET 3.5/4.0/4.5/4.5.1 with latest updates. Issue was encountered in application on .NET 3.5. Fix was to update web.config transform with

<system.webServer>  
    <handlers>
  <remove name="svc-Integrated-4.0" xdt:Transform="Insert" />
</handlers>             
</system.webServer>  

As far as I understand, System.ServiceModel.Web, Version=4.0.0.0 could not be loaded in application pool running against ASP.NET 2.0 (for apps, compiled against .NET 3.5), while svc-Integrated-4.0 handler tries to load it.


Need Your Help

How to make ssh connection in workflow through groovy script by using sand box in Jenkins?

groovy jenkins jenkins-cli groovyshell jenkins-workflow

How to make ssh connection in workflow through groovy script by using sand box in Jenkins?

How to add multiple headers to Windows Phone WebBrowser?

c# windows-phone-7 windows-phone-8 windows-phone webbrowser-control

How do you add headers to the Windows Phone web browser control? I want to add two headers, fore and back. Right now I add one header by using this: