我正在准备一个全新的ASP.NET MVC 5.1解决方案.我正在添加一堆NuGet包,并与Zurb Foundation等进行设置.
作为其中的一部分,我添加了对内部NuGet包的引用,这是一个可移植类库,我认为这会导致构建服务器出现问题.
TeamCity失败了构建:
"System.Object"类型在未引用的程序集中定义.您必须添加对程序集'System.Runtime,Version = 4.0.0.0的引用
我最初在编译Razor网页时添加了相同或类似错误的修复程序,修复了该修复程序 web.config
<compilation ... >
<assemblies>
<add assembly="System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</assemblies>
</compilation>
Run Code Online (Sandbox Code Playgroud)
但问题尚未解决.
这不是一个问题问题,而是关于装配绑定重定向工作的一般性理解问题.
查询
只有主要版本发生变化时,旧版本和新版本才会更改吗?
<dependentAssembly>
<assemblyIdentity name="FooBar"
publicKeyToken="32ab4ba45e0a69a1"
culture="en-us" />
<bindingRedirect oldVersion="7.0.0.0" newVersion="8.0.0.0" />
</dependentAssembly>
Run Code Online (Sandbox Code Playgroud)突然,在添加一些NuGet包(主要是与ASPNET标识相关)后,它开始显示此错误:
FileNotFoundException: Could not load file or assembly 'System.Runtime, Version=4.1.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
Run Code Online (Sandbox Code Playgroud)
我有针对.Net Framework 4.7.1的目标.我尝试安装NuGet包System.Runtime 4.3.0,它没有帮助.web.config文件有一个引用:
<dependentAssembly>
<assemblyIdentity name="System.Runtime" publicKeyToken="B03F5F7F11D50A3A" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-4.1.2.0" newVersion="4.1.2.0"/>
</dependentAssembly>
Run Code Online (Sandbox Code Playgroud)
bin文件夹中没有System.Runtime.dll.
有任何想法吗?
我使用Visual Studio 2017 15.5.5.
更新:
我在.csproj文件中使用PackageReference条目,因此它不是packages.config的问题.
似乎没有加载某些依赖项.
.NET Core 3.1 控制台应用程序在构建期间生成错误 -
System.IO.FileNotFoundException:无法加载文件或程序集“System.Runtime,版本=4.2.2.0,Culture=neutral,PublicKeyToken=b03f5f7f11d50a3a”。该系统找不到指定的文件。
但它适用于 .NET Core 3.0 版本。
我正在使用 Microsoft.Orleans。这是 csproj -
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Orleans.Core" Version="3.0.2" />
<PackageReference Include="Microsoft.Orleans.OrleansCodeGenerator.Build" Version="3.0.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
</Project>
Run Code Online (Sandbox Code Playgroud) 我从同事那里得到了这个项目,在构建项目时遇到了这个错误:
无法加载文件或程序集“System.Runtime,Version=4.2.1.0,Culture=neutral,PublicKeyToken=b03f5f7f11d50a3a”或其依赖项之一。该系统找不到指定的文件。
我猜这个dll位于.NET Framework Dll文件夹:中C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework,但是经过搜索,我发现了很多其他版本的dll,但我没有找到任何System.Runtime.dll是4.2.1.0。
这是另一个类似的问题,但没有答案。
System.Runtime.dll 4.2.1.0.NET Framework 中真的存在吗?
我正在尝试将 C# API 发布到 azure,我遵循了本文档中的所有步骤,但由于某种原因,当我发布应用程序时,构建会成功,但在执行以下行时会崩溃
Generating swagger file to 'C:\Users\user\Projs\API\bin\Release\netcoreapp3.1\swagger.json'.
Run Code Online (Sandbox Code Playgroud)
打印的唯一错误日志是
Failed to generate swagger file. Error dotnet swagger tofile --serializeasv2 --output "C:\Users\user\Downloads\Projs\API\bin\Release\netcoreapp3.1\swagger.json" "C:\Users\user\Downloads\Projs\API\bin\Release\netcoreapp3.1\API.dll" v1
Unhandled exception. System.IO.FileLoadException: Could not load file or assembly 'System.Runtime, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The located assembly's manifest definition does not match the assembly reference. (0x80131040)
File name: 'System.Runtime, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
Be sure that the Startup.cs for your application is calling AddSwaggerGen from within ConfigureServices in order to generate swagger file. Visit https://go.microsoft.com/fwlink/?LinkId=2131205&CLCID=0x409 …Run Code Online (Sandbox Code Playgroud) 我正在开发 C# 应用程序,在调试运行时出现以下错误:
未知模块中发生“System.IO.FileNotFoundException”类型的未处理异常。无法加载文件或程序集“System.Runtime,Version=5.0.0.0,Culture=neutral,PublicKeyToken=b03f5f7f11d50a3a”或其依赖项之一。该系统找不到指定的文件。
并且应用程序进入中断模式。
我是 C# 和 .NET 世界的新手。我正在使用 Visual Studio 进行调试。
我已经验证具有 as 返回类型的文件HttpResponseMessage设置为“编译”,就像他们在这里所说的:Why I can not use HttpResponseMessage class?
我已从packages.config迁移到packagereference(nuget),并有一个包含webapi的.net 4.7.2 mvc项目。之前它可以工作,但是在几次 Nuget 更新之后就不再工作了。我遇到了 system.web.http 和框架中 4.0.0 版本的构建以及较新的 4.x nuget 的问题。
我的问题似乎与https://github.com/Microsoft/dotnet/issues/737有关,但我不确定。
我也尝试过这个/sf/answers/3506697491/
这是我的 web.config 的一部分:
<system.web>
<globalization fileEncoding="utf-8" culture="auto" uiCulture="auto" enableClientBasedCulture="true"/>
<compilation debug="true" targetFramework="4.7.2">
<assemblies>
<add assembly="System.Net.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
</assemblies>
</compilation>
<httpRuntime targetFramework="4.7.2"/>
Run Code Online (Sandbox Code Playgroud)
using System.Net.Http;切换回 4.7.1 会使智能感知给出添加而不是的建议using System.Web.Http;,并且似乎确实修复了它。但为什么?
所以我现在可以发布“答案”:恢复到 4.7.1。所以问题是:为什么会解决这个问题?
编辑
我已手动从packages.config移至packagereference并发现:Visual Studio 2017 - 无法加载文件或程序集'System.Runtime,Version = 4.1.0.0'或其依赖项之一
它说应该有一个迁移选项。但我没有看到它并删除了 .config 文件。我已经重新安装了大部分 nuget 软件包,但System.Runtime, Version=4.2.1.0即使安装了 4.3.0 nuget,我仍然卡在这个位置。通常,VS …
今天将 Application Insights 升级到最新版本后,由于我们的站点不再报告调用堆栈,我们的 .NET Framework 4.6.1 ASP.NET 站点现在在初始化时崩溃,原因如下:
System.IO.FileLoadException: 'Could not load file or assembly 'System.Runtime, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)'
Run Code Online (Sandbox Code Playgroud)
过去我曾为另一份工作解决过一个非常相似的问题。主要区别在于该问题是由 .NET Core 或 Standard 中的 Nuget 包引起的。因此,有多个同名的 .NET DLL 被复制到 bin 文件夹(在这种情况下为 System.Net.Http)。在那种情况下,它就像不再更新那个 Nuget 包一样“容易”......
虽然我认为这里的情况略有不同,但“不升级”不再是一种选择。Application Insights 不再报告调用堆栈有点违背了整个事情的目的!
因为它是 System.Runtime,而不是 Nuget 包,所以在配置文件中没有依赖版本标记;尽管即使那样也会奏效,但这似乎是一个临时解决方案。
我的理论是,现在项目中某个地方可能隐藏了 .NET Core 的 .NET Standard,但我没有看到 NetStandard 参考,我不知道如何判断 Core 是否以某种方式被拖入。我还没有很高兴 (?) 与 Standard 或 Core 一起工作,但我还没有想到更多。我会继续谷歌搜索...
我认为这是因为我们有一个 …
c# ×8
.net ×4
asp.net ×3
nuget ×2
.net-4.7.2 ×1
.net-core ×1
asp.net-mvc ×1
azure ×1
swagger ×1