title: Could not load file or assembly 'System.ServiceModel, Version=4.0.0.0
body: <p>I recently started getting this error on my WebAPI project on VS 2017. If I run the same project on another machine it works fine. I have tried reinstalling VS 2017, reinstalling .net 4.0 and 4.5. I also tried changing the project target to 4.7 in which nothing worked. This is a similar issue but I am not running .net core 2.0 (<a href="https://stackoverflow.com/questions/45823454/asp-net-core-2-0-could-not-load-file-or-assembly-system-servicemodel">ASP.NET Core 2.0 Could not load file or assembly System.ServiceModel</a>) Any help will be much appreciated. </p>
  
  <p>I also tried adding this DLL to the project and adding it via the webconfig but didn't change anything.</p>
  
  <p>The DLL is on my system -> C:\Windows\Microsoft.NET\Framework64\v4.0.30319\System.ServiceModel.dll</p>
  
  <blockquote>
    <p>Could not load file or assembly 'System.ServiceModel, Version=4.0.0.0,
    Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its
    dependencies. The module was expected to contain an assembly manifest.</p>
    
    <p>Description: An unhandled exception occurred during the execution of
    the current web request. Please review the stack trace for more
    information about the error and where it originated in the code. </p>
    
    <p>Exception Details: System.BadImageFormatException: Could not load file
    or assembly 'System.ServiceModel, Version=4.0.0.0, Culture=neutral,
    PublicKeyToken=b77a5c561934e089' or one of its dependencies. The
    module was expected to contain an assembly manifest.</p>
    
    <p>Source Error: </p>
    
    <p>An unhandled exception was generated during the execution of the
    current web request. Information regarding the origin and location of
    the exception can be identified using the exception stack trace below.</p>
    
    <p>Assembly Load Trace: The following information can be helpful to
    determine why the assembly 'System.ServiceModel, Version=4.0.0.0,
    Culture=neutral, PublicKeyToken=b77a5c561934e089' could not be loaded.</p>
    
    <p>Assembly manager loaded from: 
    C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll Running under
    executable  C:\Program Files (x86)\IIS Express\iisexpress.exe
    --- A detailed error log follows. </p>
    
    <p>=== Pre-bind state information === LOG: DisplayName = System.ServiceModel, Version=4.0.0.0, Culture=neutral,
    PublicKeyToken=b77a5c561934e089  (Fully-specified) LOG: Appbase =
    file:///C:/Users/Michael/Desktop/Project/API/ LOG:
    Initial PrivatePath = C:\Users\Michael\Desktop\Project\API\bin Calling assembly : (Unknown).
    === LOG: This bind starts in default load context. LOG: Using application configuration file: C:\Users\Michael\Desktop\Project\API\web.config LOG: Using host configuration file:
    C:\Users\Michael\Documents\IISExpress\config\aspnet.config LOG: Using
    machine configuration file from
    C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
    LOG: Post-policy reference: System.ServiceModel, Version=4.0.0.0,
    Culture=neutral, PublicKeyToken=b77a5c561934e089</p>
    
    <p>Stack Trace: </p>
    
    <p>[BadImageFormatException: Could not load file or assembly
    'System.ServiceModel, Version=4.0.0.0, Culture=neutral,
    PublicKeyToken=b77a5c561934e089' or one of its dependencies. The
    module was expected to contain an assembly manifest.]<br>
    System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String
    codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint,
    StackCrawlMark&amp; stackMark, IntPtr pPrivHostBinder, Boolean
    throwOnFileNotFound, Boolean forIntrospection, Boolean
    suppressSecurityChecks) +0<br>
    System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String
    codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint,
    StackCrawlMark&amp; stackMark, IntPtr pPrivHostBinder, Boolean
    throwOnFileNotFound, Boolean forIntrospection, Boolean
    suppressSecurityChecks) +36<br>
    System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName
    assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly,
    StackCrawlMark&amp; stackMark, IntPtr pPrivHostBinder, Boolean
    throwOnFileNotFound, Boolean forIntrospection, Boolean
    suppressSecurityChecks) +152<br>
    System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString,
    Evidence assemblySecurity, StackCrawlMark&amp; stackMark, IntPtr
    pPrivHostBinder, Boolean forIntrospection) +77<br>
    System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString,
    Evidence assemblySecurity, StackCrawlMark&amp; stackMark, Boolean
    forIntrospection) +21    System.Reflection.Assembly.Load(String
    assemblyString) +28<br>
    System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String
    assemblyName, Boolean starDirective) +38</p>
    
    <p>[ConfigurationErrorsException: Could not load file or assembly
    'System.ServiceModel, Version=4.0.0.0, Culture=neutral,
    PublicKeyToken=b77a5c561934e089' or one of its dependencies. The
    module was expected to contain an assembly manifest.]<br>
    System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String
    assemblyName, Boolean starDirective) +738<br>
    System.Web.Configuration.CompilationSection.LoadAssembly(AssemblyInfo
    ai) +57<br>
    System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection
    compConfig) +170<br>
    System.Web.Compilation.BuildManager.GetPreStartInitMethodsFromReferencedAssemblies()
    +92    System.Web.Compilation.BuildManager.CallPreStartInitMethods(String
    preStartInitListPath, Boolean&amp; isRefAssemblyLoaded) +290<br>
    System.Web.Compilation.BuildManager.ExecutePreAppStart() +157<br>
    System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager
    appManager, IApplicationHost appHost, IConfigMapPathFactory
    configMapPathFactory, HostingEnvironmentParameters hostingParameters,
    PolicyLevel policyLevel, Exception appDomainCreationException) +549</p>
    
    <p>[HttpException (0x80004005): Could not load file or assembly
    'System.ServiceModel, Version=4.0.0.0, Culture=neutral,
    PublicKeyToken=b77a5c561934e089' or one of its dependencies. The
    module was expected to contain an assembly manifest.]<br>
    System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +10042604
    System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +95
    System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest
    wr, HttpContext context) +254</p>
  </blockquote>