Venkat
Venkat

Reputation: 2186

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

This is what I did:

went to https://www.twilio.com/docs/authy/tutorials/account-verification-csharp-mvc

downloaded the code and built the code using VS2017 community edition. I get the following error in IdentityConfig.cs

Severity Code Description Project File Line Suppression State Error CS0246 The type or namespace name 'TwilioRestClient' could not be found (are you missing a using directive or an assembly reference?) AccountVerification.Web C:\Users\admin\Downloads\account-verification-csharp-master\account-verification-csharp-master\AccountVerification.Web\App_Start\IdentityConfig.cs 21 Active

What is the problem?

I changed nothing. Just downloaded and built the code. Shouldn't you guys give a working copy of the code?

Upvotes: 3

Views: 1579

Answers (1)

Karel Tamayo
Karel Tamayo

Reputation: 3750

I've managed to get this working by following these steps:

  1. Close the solution in Visual Studio if you have it opened.
  2. Ensure you have a nuget CLI in your path. So you can run a restore from a command prompt. This is pretty straightforward. Instructions here.
  3. Open a command prompt at the solution directory. (C:\Users\admin\Downloads\account-verification-csharp-master\account-verification-csharp-master for you.)
  4. Run a nuget restore. nuget restore and wait for it to finish.
  5. You should get all the packages downloaded at the packages directory under your solution folder.

    UPDATE - Looking at the code it appears that there's a mix of features from the latest version 5.x and the now deprecated version 4.x, and that's causing compilation errors. Details here.

Follow the below steps to downgrade the version to 4.7.2:

  1. Open the solution file now.
  2. Right-click the web project and select Manage Nuget Packages.
  3. Search for Twilio and downgrade the version from 5.x to 4.7.2.

    a) Or from the Package Manager Console Install-Package Twilio -Version 4.7.2

  4. Solution should build successfully now.
  5. Please bear in mind that you must setup the parameters in Local.config file before the app can work. It'll run though, but you'll not be able to go through it until the parameters are properly set.

Note: The solution contains a file named Local.config.example. When you open the solution you'll notice that Local.config file is missing.

missing Local.config file

Renaming the existing Local.config.example file to Local.config solves that issue. I had to copy the Local.config file to the test project too. This doesn't prevent the solution from building, though.

Hope this helps!

Upvotes: 2

Related Questions