我有一个 .NET Core 应用程序,想要使用 Twilio,因此我从命令行执行了以下操作。
dotnet add package Twilio
一切都进行得很顺利,没有出现错误。它添加了Twilio包的5.1.1版本。但是现在构建应用程序会给我造成麻烦。
The type or namespace name 'Twilio' could not be found
我正在运行 .Net Core 1.1 版本,使用的是等效的 1.0.1 SDK。
你有任何想法吗?
我有一个 .NET Core 应用程序,想要使用 Twilio,因此我从命令行执行了以下操作。
dotnet add package Twilio
The type or namespace name 'Twilio' could not be found
你有任何想法吗?
你进行了恢复吗?以下内容对我有效。
dotnet new console
dotnet add package Twilio
dotnet restore <---- We need to restore after adding a package.
dotnet build
Program.cs
using Twilio;
class Program
{
static void Main(string[] args)
{
TwilioClient.SetUsername("foo");
}
}
DotNetCoreTwilio.csproj
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp1.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Twilio" Version="5.1.1" />
</ItemGroup>
</Project>
using Twilio.Types;
当Visual Studio被引用如下时,它没有提供任何建议:
twilio.Types.PhoneNumber("xx");
PhoneNumber("xx");
希望这能帮助到某个人