Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

System.MissingMethodException when ITwilioRestClient created via DI #768

Open
keltex opened this issue Nov 7, 2024 · 0 comments
Open

System.MissingMethodException when ITwilioRestClient created via DI #768

keltex opened this issue Nov 7, 2024 · 0 comments

Comments

@keltex
Copy link

keltex commented Nov 7, 2024

Issue Summary

This is a dotnetcore application running on dotnet 7. When attempting to instatiate a ITwilioRestClient via dependency injection, I get the following exception:

System.MissingMethodException: 'Method not found: 'Void Twilio.Clients.TwilioRestClient..ctor(System.String, System.String, System.String, System.String, Twilio.Http.HttpClient, System.String)'.'

This is happening on twilio 7.6.0. If I roll back to twilio 7.5.1 the bug does not occur.

Steps to Reproduce

  1. Nuget to install twilio version 7.6.0
  2. Configure twilio in startup.cs
  3. Attempt to instantiate a ITwilioRestClient via DI

Code Snippet

Here's my code to create the service in startup.cs

services.AddTwilioClient(optionsToConfigure =>
{
    auction4.Services.Utility.TwilioUtil.SetOptions(Configuration, optionsToConfigure);
});

Then the exception occurs when my razor page loads:

private readonly ITwilioRestClient _twilioClient;
private readonly IConfiguration _configuration;

public TwilioSendModel(IConfiguration configuration, 
    ITwilioRestClient twilioClient)
{
    _twilioClient = twilioClient;
    _configuration = configuration;
}

Exception/Log

System.MissingMethodException
  HResult=0x80131513
  Message=Method not found: 'Void Twilio.Clients.TwilioRestClient..ctor(System.String, System.String, System.String, System.String, Twilio.Http.HttpClient, System.String)'.
  Source=Twilio.AspNet.Core
  StackTrace:
   at Twilio.AspNet.Core.TwilioClientDependencyInjectionExtensions.CreateTwilioClient(IServiceProvider provider)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitFactory(FactoryCallSite factoryCallSite, RuntimeResolverContext context)

Technical details:

  • twilio-csharp version: 7.6.0
  • csharp version: 7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant