在Linux中,找不到".NETFramework,Version=v4.5"框架的参考程序集。

4

我已经在我的Ubuntu机器上安装了Visual Studio,以编译C#代码。

我将工作空间/我的代码加载到VS中,但是我看到了以下错误:

    The reference assemblies for framework ".NETFramework,Version=v4.5" were not found. To resolve this, install the SDK or Targeting Pack for this framework version or retarget your application to a version of the framework for which you have the SDK or Targeting Pack installed. Note that assemblies will be resolved from the Global Assembly Cache (GAC) and will be used in place of reference assemblies. Therefore your assembly may not be correctly targeted for the framework you intend.

请帮我解决这个问题,因为我是 Visual Studio 的初学者。
谢谢。

6
你不能在Linux上使用.NET Framework v4.5,你必须使用.NET Core。 - suchoss
@suchoss 感谢您的回复。您能帮我解决如何迁移到 .net core 的问题吗? - Pradip
@suchoss Mono项目可以实现此功能,无需降级到.NET Core。 - Alejandro
@Alejandro 我从未使用过mono,所以我无法发表评论。但是已经有一个关于转换到 .net core 的答案了。 - suchoss
如果你真的是.NET Framework的初学者,那就坚持使用Windows和Visual Studio。如果你没有学习.NET Core的计划(为什么你甚至不会去谷歌搜索学习.NET Core的地方),那就别想在Linux上玩Mono。专注并不要浪费时间。 - Lex Li
2个回答

3
如果项目较为庞大,您可以按照此流程进行操作。
如果您的项目较为轻量级,请使用VS创建一个新的.netcore项目,并将您的代码(以及依赖项引用)移动到这个新项目中。然后让VS告诉您潜在的错误并予以纠正。
看一下这个过程,您可以首先将您现有的项目定位到dotnet 4.6.2框架上,以“确保您可以在.NET Core无法支持特定API的情况下使用针对.NET Framework特定目标的API替代方法。”

我可以在左侧看到一些可安装的内容。我安装了 .net core。之后,我将框架从 v4.5 更改为 .netcore。现在出现了一个新问题,如下所示:/usr/share/dotnet/sdk/2.1.300/Microsoft.Common.CurrentVersion.targets(83,5): error MSB4184: 无法评估表达式 "[Microsoft.Build.Utilities.ToolLocationHelper]::GetPathToStandardLibraries(.NETFramework, netcoreapp2.1, '', '', '')"。输入字符串格式不正确。[/home/teuser/Desktop/Task on Set-top Box/newEthos/TeSkyEthos/DataEngine/DataEngine.csproj] - Pradip

0
如果您有Visual Studio 2017,我建议您运行可移植性工具。这将让您了解是否在迁移时会遇到困难。
至于csproj的错误,那是因为该文件中包含路径,这些路径使用Windows路径而非Linux路径指向位置。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接