Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The type or namespace name 'Twilio' could not be found

So I've got a dotnet core app, I'd like to use Twilio so I performed the following from the command line.

dotnet add package Twilio

All went well, no errors. It adds version 5.1.1 of Twilio packages. But building the app now gives me

The type or namespace name 'Twilio' could not be found

I'm running .Net core version 1.1 with the equivalent 1.0.1 SDK.

Any ideas?

like image 612
Senkwe Avatar asked Oct 15 '25 13:10

Senkwe


1 Answers

Did you restore? The following works for me.

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>                                                
like image 95
Shaun Luttin Avatar answered Oct 17 '25 02:10

Shaun Luttin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!