从1.1.1升级错误:“System.IO.FileSystem.Primitives”和“System.Runtime,Version = 4.2.0.0

时间:2017-04-22 19:59:19

标签: asp.net-core .net-core

将我的项目更新为1.1.1后,以下两行不起作用: var d = new FileStream(Path.Combine(PathToFile, $"{fileName}.txt"), FileMode.Open); var fs = new StreamReader(d,Encoding.UTF8);

当我将chane恢复为csproj文件时,错误消失了。我做错了什么?

我收到以下错误:

  1. 错误CS0433“System.IO,Version = 4.1.0.0,Culture = neutral,PublicKeyToken = b03f5f7f11d50a3a”和“System.Runtime.Extensions,Version = 4.2.0.0,Culture = neutral”中存在“StreamReader”类型公钥= b03f5f7f11d50a3a'
  2. 错误CS0433类型'FileMode'存在于'System.IO.FileSystem.Primitives,Version = 4.0.1.0,Culture = neutral,PublicKeyToken = b03f5f7f11d50a3a'和'System.Runtime,Version = 4.2.0.0,Culture =中性,PublicKeyToken = b03f5f7f11d50a3a'
  3. 错误CS0433“编码”类型同时存在于'System.Text.Encoding,Version = 4.0.10.0,Culture = neutral,PublicKeyToken = b03f5f7f11d50a3a'和'System.Runtime,Version = 4.2.0.0,Culture = neutral,公钥= b03f5f7f11d50a3a'
  4. 错误CS0433“编码”类型同时存在于'System.Text.Encoding,Version = 4.0.10.0,Culture = neutral,PublicKeyToken = b03f5f7f11d50a3a'和'System.Runtime,Version = 4.2.0.0,Culture = neutral,公钥= b03f5f7f11d50a3a'
  5. 错误CS1503参数1:无法从'string'转换为'System.IntPtr'
  6. 我的csproj文件是:

    <Project Sdk="Microsoft.NET.Sdk.Web">
      <PropertyGroup>
        <TargetFramework>netcoreapp1.1</TargetFramework>
        <DebugType>portable</DebugType>
        <AssemblyName>Backend</AssemblyName>
        <OutputType>Exe</OutputType>
        <PackageId>Backend</PackageId>
        <PackageTargetFallback>portable-net45+win8</PackageTargetFallback>
        <DockerComposeProjectPath>..\docker-compose.dcproj</DockerComposeProjectPath>
      </PropertyGroup>
      <ItemGroup>
        <Compile Remove="Model\**" />
        <Content Remove="Model\**" />
        <EmbeddedResource Remove="Model\**" />
        <None Remove="Model\**" />
      </ItemGroup>
      <ItemGroup>
        <ProjectReference Include="..\Engine\Engine.csproj" />
      </ItemGroup>
      <ItemGroup>
        <PackageReference Include="Microsoft.AspNetCore" Version="1.1.1" />
        <PackageReference Include="Microsoft.AspNetCore.Diagnostics" Version="1.1.1" />
        <PackageReference Include="Microsoft.AspNetCore.Server.IISIntegration" Version="1.1.1" />
        <PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="1.1.1" />
        <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="1.1.1" />
        <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="1.1.1" />
        <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer.Design" Version="1.1.1" />
        <PackageReference Include="Microsoft.Extensions.Logging.Console" Version="1.1.1" />
        <PackageReference Include="Microsoft.AspNetCore.ResponseCompression" Version="1.0.1" />
        <PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="1.1.1" />
        <PackageReference Include="Microsoft.VisualStudio.Web.BrowserLink" Version="1.1.0" />
        <PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="1.1.0" />
      </ItemGroup>
      <ItemGroup Condition=" '$(TargetFramework)' == 'netcoreapp1.1' ">
        <PackageReference Include="Microsoft.AspNetCore.Server.Kestrel" Version="1.1.1" />
        <PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.1.2" />
        <PackageReference Include="Microsoft.AspNetCore.Mvc.Core" Version="1.1.2" />
        <PackageReference Include="Microsoft.AspNetCore.Cors" Version="1.1.1" />
        <PackageReference Include="System.ValueTuple" Version="4.3.0" />
      </ItemGroup>
      <ItemGroup>
        <DotNetCliToolReference Include="Microsoft.DotNet.Watcher.Tools" Version="1.0.0-msbuild3-final" />
      </ItemGroup>
    </Project>
    

    以前的版本:

    <Project Sdk="Microsoft.NET.Sdk.Web">
      <PropertyGroup>
        <TargetFramework>netcoreapp1.1</TargetFramework>
        <DebugType>portable</DebugType>
        <AssemblyName>Backend</AssemblyName>
        <OutputType>Exe</OutputType>
        <PackageId>Backend</PackageId>
        <PackageTargetFallback>portable-net45+win8</PackageTargetFallback>
        <DockerComposeProjectPath>..\docker-compose.dcproj</DockerComposeProjectPath>
      </PropertyGroup>
      <ItemGroup>
        <Compile Remove="Model\**" />
        <Content Remove="Model\**" />
        <EmbeddedResource Remove="Model\**" />
        <None Remove="Model\**" />
      </ItemGroup>
      <ItemGroup>
        <ProjectReference Include="..\Engine\Engine.csproj" />
      </ItemGroup>
      <ItemGroup>
        <PackageReference Include="Microsoft.AspNetCore" Version="1.1.0" />
        <PackageReference Include="Microsoft.AspNetCore.Diagnostics" Version="1.0.1" />
        <PackageReference Include="Microsoft.AspNetCore.Server.IISIntegration" Version="1.0.1" />
        <PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="1.1.0" />
        <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="1.1.0" />
        <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="1.1.0" />
        <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer.Design" Version="1.1.0" />
        <PackageReference Include="Microsoft.Extensions.Logging.Console" Version="1.1.0" />
        <PackageReference Include="Microsoft.AspNetCore.ResponseCompression" Version="1.0.0" />
        <PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="1.1.0" />
        <PackageReference Include="Microsoft.VisualStudio.Web.BrowserLink" Version="1.0.0" />
        <PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="1.1.0-msbuild3-final" />
      </ItemGroup>
      <ItemGroup Condition=" '$(TargetFramework)' == 'netcoreapp1.1' ">
        <PackageReference Include="Microsoft.AspNetCore.Server.Kestrel" Version="1.1.0" />
        <PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.1.0" />
        <PackageReference Include="Microsoft.AspNetCore.Mvc.Core" Version="1.1.0" />
        <PackageReference Include="Microsoft.AspNetCore.Cors" Version="1.1.0" />
        <PackageReference Include="System.IO" Version="4.3.0" />
        <PackageReference Include="System.ValueTuple" Version="4.3.0" />
      </ItemGroup>
      <ItemGroup>
        <DotNetCliToolReference Include="Microsoft.DotNet.Watcher.Tools" Version="1.0.0-msbuild3-final" />
      </ItemGroup>
    </Project>
    

2 个答案:

答案 0 :(得分:1)

请参阅here

  

重建nuget包会修复它。   转到%USERPROFILE%/。nuget并清除所有内容。

here

  

@ericwj据网络工具团队的乔,   这是一个已知问题。有一个版本的BrowserLink包有错误的引用,而显然是随.NET Core 1.1 CLI安装程序一起提供的。但是,在RC.3中,我们从Core 1.1模板中删除了BrowserLink,因此它不应该是新项目的问题。

答案 1 :(得分:0)

在我的情况下,这是在安装SPA模板后发生的。我不得不修复视觉工作室,以便它可以修复版本。