Skip to content

Could not load file or assembly 'System.Net.Http' #436

@zkost

Description

@zkost

I've been using Twilio for many years. Awesome product and service! When it works, it works reliably, when it breaks it breaks reliably. I'm not sure if this is a Twilio issue or a Twilio symptom considering the many, many .net changes going on.

Version:
vs2017 15.7.5
.Net 4.7.2 (version 4.7.03056)
Twilio 5.14.1.0

Code Snippet

      string _fromNumber = "+1....";
      string _accountSid = "....";
      string _authToken = "....";

      // Find your Account Sid and Auth Token at twilio.com/console
      TwilioClient.Init(_accountSid, _authToken);

      CreateMessageOptions sms = new CreateMessageOptions(new Twilio.Types.PhoneNumber("+1...."))
      {
        From = new Twilio.Types.PhoneNumber(_fromNumber),

        // only send the first 160 characters of a message.
        Body = "Test"
      };
	  // this next line of code is where the exception is thrown
      MessageResource.Create(sms);

Exception/Log

An unhandled exception of type 'System.IO.FileNotFoundException' occurred in mscorlib.dll
Additional information: Could not load file or assembly 'System.Net.Http, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.

Steps to Reproduce

  1. Blank new project. Set to 4.7.2, install Twilio 5.14.1.0 and download dependencies from nuget
  2. Run the above code and you get the exception. I confirm that System.net.http verson

My app.config

<runtime>
   ....
         <dependentAssembly>
            <assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
            <bindingRedirect oldVersion="0.0.0.0-4.2.0.0" newVersion="4.2.0.0" />
         </dependentAssembly>

Considerations:

  1. First guess is that there is a reference issue in Twilio.dll 5.14.1.0 when running 4.7.2
  2. Twilio 5.14.1.0 is not compatible with Net 4.7.2
  3. The exception is a red herring for some other exception not bubbling up.
  4. This very well be within my code, but I can't make it any more vanilla.

Is anyone else experiencing this or similiar issue? For me downgrading is not an option. Any insight is greatly appreciated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions