我在ubuntu上,我使用VSCode和.NET CORE,我在命令面板上安装了一个名为Otter的软件包。
我的.csproj现在是这样的:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Otter" Version="0.9.8.926"/>
</ItemGroup>
我的主要.cs文件是:
using System;
using Otter;
namespace helloWorldFromCSharp
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello");
}
}
}
但是当我尝试用以下方法构建我的项目时:
dotnet build
我收到此错误:
Program.cs(2,7): error CS0246: The type or namespace name 'Otter' could not be found (are you missing a using directive or an assembly reference?) [/home/erwan/Documents/helloWorldFromCSharp/helloWorldFromCSharp.csproj]
我不知道如何解决它。
我用一个简单的.Net Core App测试来重现这个问题。我有同样的问题。
Otter在.Net Framework 4.5中,因此它不适用于Asp.Net核心应用程序。
由于您使用的是Ubuntu,因此您无法切换到Asp.Net MVC。我建议你寻找在.Net Core或.Net Standard中编写的另一个2d框架(不知道是否可行)
看看Otter.csproj
:
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
意思是,您无法从编译为netcoreapp2.1
的项目中引用它
您可能希望克隆项目并尝试将其定位到合适的框架版本(如果可能)。