.Net Core Web API System.Reflection.ReflectionTypeLoadException when dependent projects have framework dll System.Web.Services reference


I have a .net core API version 3.1 which is having dependency on 2 projects.

  1. Net Framework Target 4.7.2 project library.
  2. .Net Standard library

Legacy .Net Framework 4.7 project using framework dlls - System.Web.Services and System.Configuration for calling Soap based asmx web service and for reading configuration from web.confg respectively.

Inside .Net Standard library i created below AuthorizationFilter by adding package Microsoft.AspNetCore.Mvc.Abstractions

/// <inheritdoc/>
public void OnAuthorization(AuthorizationFilterContext context)
    if (!AllPossibleLocalHostUrls.Any(x => x.Equals(context.HttpContext.Request.Host.Value, StringComparison.OrdinalIgnoreCase)))
        context.Result = null;

Once the package Microsoft.AspNetCore.Mvc.Abstractions is added during application startup get below error:

System.Reflection.ReflectionTypeLoadException: 'Unable to load one or more of the requested types. Could not load file or assembly 'System.Web.Services, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified. Could not load file or assembly 'System.Configuration.ConfigurationManager, Version=, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. The located assembly's manifest definition does not match the assembly reference. (0x80131040)'

Error Message

I am able to resolve the 2nd error by adding nuget package System.Configuration.ConfigurationManager inside .Net Standard Library project. But for System.Web.Services unable to find any nuget package available for .Net Core applications.

asked on Stack Overflow Aug 22, 2020 by Abhinav Sharma • edited Aug 22, 2020 by ndogac

0 Answers

Nobody has answered this question yet.

User contributions licensed under CC BY-SA 3.0