System.IO.Stream usage is identified as incompatible type when overriding FileConfigurationProvider

I am trying to create a custom FileConfigurationProvider implementation of some configuration items 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, overriding Load(Stream stream)

gives me an indicator in VS2017 that there is no suitable method to override. Also, an additional hint of error indicates that FileConfigurationProvider(System.IO.Stream) is not implemented

.

Retrieving the delegate using ReSharper brought up a new call hint Load(Stream stream)

stating thatArgument 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?

Csproj looks like this.

    <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 also tried to be more explicit within the defs ...

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

      

+3


source to share


1 answer


JetBrains error driver has a bug https://youtrack.jetbrains.com/issue/RSRP-464676



+7


source







All Articles