本文介绍了从 1.1.1 升级错误:“FileMode"存在于“System.IO.FileSystem.Primitives"和“System.Runtime, Version=4.2.0.0"中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

After updating my project to 1.1.1 the following two lines do not work:var d = new FileStream(Path.Combine(PathToFile, $"{fileName}.txt"), FileMode.Open); var fs = new StreamReader(d,Encoding.UTF8);

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

When I reverted the chane to the csproj file, the error disappeared. What am I doing wrong?

我收到以下错误:

  1. 错误 CS0433 类型StreamReader"存在于System.IO, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"和System.Runtime.Extensions, Version=4.2.0.0, Culture=neutral,PublicKeyToken=b03f5f7f11d50a3a'
  2. 错误 CS0433 '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,PublicKeyToken=b03f5f7f11d50a3a'
  4. 错误 CS0433 'System.Text.Encoding, Version=4.0.10.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' 和 'System.Runtime, Version=4.2.0.0, Culture=neutral,PublicKeyToken=b03f5f7f11d50a3a'
  5. 错误 CS1503 参数 1:无法从字符串"转换为System.IntPtr"

我的 csproj 文件是:

My csproj file is:

<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="..EngineEngine.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="..EngineEngine.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>

推荐答案

参见 这里

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

还有这里

@ericwj 根据网络工具团队的 joe 所说,这是一个已知问题.有一个包含错误引用的 BrowserLink 包版本,这显然是 .NET Core 1.1 CLI 安装程序附带的版本.但是,在 RC.3 中,我们从 Core 1.1 模板中删除了 BrowserLink,因此新项目应该不会出现问题.

这篇关于从 1.1.1 升级错误:“FileMode"存在于“System.IO.FileSystem.Primitives"和“System.Runtime, Version=4.2.0.0"中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-14 01:32