Use of System.IO.Stream detected as an incompatible type when overriding FileConfigurationProvider

Viewed 876

I'm attempting to create a custom FileConfigurationProvider implementation for some configuration elements in a .Net Core WebApi application.

It looks something like this..

public class MyProvider : FileConfigurationProvider
{
    public MyProvider(FileConfigurationSource source) : base(source) { }

    public override void Load(Stream stream)
    {
        try
        {
          // Stream reading things
        }
        catch
        {
            throw new Exception("Failed to load stream.");
        }
    }
}

Despite the simplicity of this example, the override of Load(Stream stream) gives me an indicator in VS2017 that there is no suitable method for override. Furthermore an additional error hint states that FileConfigurationProvider(System.IO.Stream) is not implemented.

Extracting to a delegate using ReSharper has revealed a new hint for the call to Load(Stream stream) stating that Argument type System.IO.Stream [System.IO, Version=4.1.0.0...] is not assignable to parameter of type System.IO.Stream [System.Private.CoreLib, Version=4.0.0.0...]

Despite these error hints I can still successfully build and run this code.

Can someone help me understand what is wrong here?

The csproj is as follows..

    <Project Sdk="Microsoft.NET.Sdk.Web">

  <PropertyGroup>
    <TargetFramework>netcoreapp1.1</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <Folder Include="wwwroot\" />
  </ItemGroup>
  <ItemGroup>
    <PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.0.0" />
    <PackageReference Include="Microsoft.AspNetCore" Version="1.1.2" />
    <PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.1.3" />
    <PackageReference Include="Microsoft.Extensions.Configuration" Version="1.1.2" />
    <PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="1.1.2" />
    <PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="1.1.2" />
  </ItemGroup>
  <ItemGroup>
    <DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="1.0.1" />
  </ItemGroup>

</Project>

I've also tried being more explicit in the framework defs...

  <PropertyGroup>
    <TargetFramework>netcoreapp1.1</TargetFramework>
    <NetStandardImplicitPackageVersion>1.6.1</NetStandardImplicitPackageVersion>
    <RuntimeFrameworkVersion>1.1.2</RuntimeFrameworkVersion>
  </PropertyGroup>
1 Answers
Related