將我的項目更新到1.1.1後,以下兩行不會工作: var d = new FileStream(Path.Combine(PathToFile, $"{fileName}.txt"), FileMode.Open); var fs = new StreamReader(d,Encoding.UTF8);
從1.1.1升級錯誤:'FileMode'存在於'System.IO.FileSystem.Primitives'和'System.Runtime,Version = 4.2.0.0
當我將chane恢復到csproj文件時,錯誤消失。我究竟做錯了什麼?
我得到以下錯誤:
- 錯誤CS0433類型 '的StreamReader' 存在於兩個 'System.IO,版本= 4.1.0.0,文化=中性公鑰= b03f5f7f11d50a3a' 和「System.Runtime .Extensions,Version = 4.2.0.0,Culture = neutral,PublicKeyToken = b03f5f7f11d50a3a'
- 錯誤CS0433'System.IO.FileSystem.Primitives,Version = 4.0.1.0,Culture = neutral,PublicKeyToken'中存在'FileMode' = b03f5f7f11d50a3a'和'System.Runtime,Version = 4.2.0.0,Culture = neutral,PublicKeyToken = b03f5f7f11d50a3a'
- 錯誤CS0433類型'編碼'System.Text.Encoding,Version = 4.0.10.0,Culture = neutral,PublicKeyToken = b03f5f7f11d50a3a'和'System.Runtime,Version = 4.2.0.0,Culture = neutral,PublicKeyToken = b03f5f7f11d50a3a'
- 錯誤CS0433 「System.Text.Encoding,Version = 4.0.10.0,Culture = neutral,PublicKeyToken = b03f5f7f11d50a3a」和「System.Runtime,Version = 4.2.0.0,Culture = neutral,PublicKeyToken = b03f5f7f11d50a3a' 中都存在類型'Encoding'
- 錯誤CS1503參數1:無法從 '串' 到 'System.IntPtr'
我的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>
以前版本包含了'System.IO' – VMAtm
我測試你的建議裝基準,它沒沒有幫助 - 我仍然遇到錯誤。特別有趣的是版本衝突是基於IO版本4。** 1 **,即使我安裝了版本4。** 3 **。 – Relman