gpt4 book ai didi

c# - 无法在 .NET Core 中加载文件或程序集 'System.Runtime, Version=4.1.0.0'

转载 作者:太空狗 更新时间:2023-10-29 21:56:44 25 4
gpt4 key购买 nike

Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly 'System.Runtime, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.

at System.ModuleHandle.ResolveType(RuntimeModule module, Int32 typeToken, IntPtr* typeInstArgs, Int32 typeInstCount, IntPtr* methodInstArgs, Int32 methodInstCount, ObjectHandleOnStack type)
at System.ModuleHandle.ResolveTypeHandleInternal(RuntimeModule module, Int32 typeToken, RuntimeTypeHandle[] typeInstantiationContext, RuntimeTypeHandle[] methodInstantiationContext)
at System.Reflection.RuntimeModule.ResolveType(Int32 metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments)
at System.Reflection.CustomAttribute.FilterCustomAttributeRecord(CustomAttributeRecord caRecord, MetadataImport scope, Assembly& lastAptcaOkAssembly, RuntimeModule decoratedModule, MetadataToken decoratedToken, RuntimeType attributeFilterType, Boolean mustBeInheritable, Object[] attributes, IList derivedAttributes, RuntimeType& attributeType, IRuntimeMethodInfo& ctor, Boolean& ctorHasParameters, Boolean& isVarArg)
at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeModule decoratedModule, Int32 decoratedMetadataToken, Int32 pcaCount, RuntimeType attributeFilterType, Boolean mustBeInheritable, IList derivedAttributes, Boolean isDecoratedTargetSecurityTransparent)
at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeAssembly assembly, RuntimeType caType)
at System.Attribute.GetCustomAttributes(Assembly element, Type attributeType, Boolean inherit)
at System.AppDomain.GetTargetFrameworkName()

我在我的应用程序中使用 AssemblyLoadContext,所以我有 "System.Runtime.Loader": "4.0.0"作为依赖项,但在发布我的项目后我有上述错误。

dotnet --version
1.0.0-preview2-003121

{
"version": "1.0.0-*",
"buildOptions": {
"emitEntryPoint": true
},

"dependencies": {
"Microsoft.NETCore.App": {
"type": "platform",
"version": "1.0.0"
},
"CommandLineArgumentsParser": "3.0.4",
"System.Runtime.Loader": "4.0.0",
"Microsoft.Extensions.DependencyModel": "1.0.0",
"System.Runtime": "4.1.0"
},

"frameworks": {
"netcoreapp1.0": {
"imports": "dnxcore50"
}
}
}

使用 visual studio 我可以运行我的应用程序但是使用 dotnet 命令行我有上述错误。有人可以帮助我吗?

最佳答案

您“将项目创建为 .NET 4.6.2”并尝试使用 dotnet core 进行编译。您需要在第一个或第二个之间做出选择。发生错误是因为项目文件 vcxproj 引用了 .net 4.6.2,而 dotnet 将无法使其正常工作。

今天,您可能想要清理您的 vcxproj 文件以及您的 dotnet 配置,将您的源代码迁移到一个新项目(我推荐 dotnet core 2),这应该会运行。

关于c# - 无法在 .NET Core 中加载文件或程序集 'System.Runtime, Version=4.1.0.0',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39462121/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com