EasyPost/easypost-csharp

RestSharp issue

Closed this issue · 18 comments

I have updated to latest version of EasyPost but while calling create method I am getting below error
Method not found: 'Void RestSharp.RestRequest..ctor(System.String, RestSharp.Method)'.

EasyPost Version : 2.5.1
RestSharp Version : 106.5.2

Any help on this?

@dktechindia What .net version are you targeting?

its 4.7.1

@dktechindia I can verify that you are correct with RestSharp version 106.5.2 that error is encountered.

@att14 The problem does not occur with RestSharp 106.4.2... I tested targeting net472

Full Error I received:

Method not found: 'Void RestSharp.RestRequest..ctor(System.String, RestSharp.Method)'.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.MissingMethodException: Method not found: 'Void RestSharp.RestRequest..ctor(System.String, RestSharp.Method)'.

Source Error: 
Line 85:             };
Line 86: 
Line 87:             shipment.Buy(shipment.LowestRate(
Line 88:                 includeServices: new List<string>() { "Priority" },
Line 89:                 includeCarriers: new List<string>() { "USPS" }

Stack Trace: 
[MissingMethodException: Method not found: 'Void RestSharp.RestRequest..ctor(System.String, RestSharp.Method)'.]
   EasyPost.Request..ctor(String IResource, Method method) +0
   EasyPost.Shipment.sendCreate(Dictionary`2 parameters) +35
   EasyPost.Shipment.Create() +27
   EasyPost.Shipment.GetRates() +20
   EasyPost.Shipment.LowestRate(IEnumerable`1 includeCarriers, IEnumerable`1 includeServices, IEnumerable`1 excludeCarriers, IEnumerable`1 excludeServices) +82
   Ep472.Controllers.HomeController.Easypost() in C:\Dev\Ep472\Ep472\Controllers\HomeController.cs:87
   lambda_method(Closure , ControllerBase , Object[] ) +62
   System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters) +14
   System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters) +169
   System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +27
   System.Web.Mvc.Async.<>c.<BeginInvokeSynchronousActionMethod>b__9_0(IAsyncResult asyncResult, ActionInvocation innerInvokeState) +22
   System.Web.Mvc.Async.WrappedAsyncResult`2.CallEndDelegate(IAsyncResult asyncResult) +29
   System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +49
   System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult) +32
   System.Web.Mvc.Async.AsyncInvocationWithFilters.<InvokeActionMethodFilterAsynchronouslyRecursive>b__11_0() +50
   System.Web.Mvc.Async.<>c__DisplayClass11_1.<InvokeActionMethodFilterAsynchronouslyRecursive>b__2() +228
   System.Web.Mvc.Async.<>c__DisplayClass7_0.<BeginInvokeActionMethodWithFilters>b__1(IAsyncResult asyncResult) +10
   System.Web.Mvc.Async.WrappedAsyncResult`1.CallEndDelegate(IAsyncResult asyncResult) +10
   System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +49
   System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethodWithFilters(IAsyncResult asyncResult) +34
   System.Web.Mvc.Async.<>c__DisplayClass3_6.<BeginInvokeAction>b__3() +35
   System.Web.Mvc.Async.<>c__DisplayClass3_1.<BeginInvokeAction>b__5(IAsyncResult asyncResult) +100
   System.Web.Mvc.Async.WrappedAsyncResult`1.CallEndDelegate(IAsyncResult asyncResult) +10
   System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +49
   System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult) +27
   System.Web.Mvc.<>c.<BeginExecuteCore>b__152_1(IAsyncResult asyncResult, ExecuteCoreState innerState) +11
   System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +29
   System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +49
   System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +45
   System.Web.Mvc.<>c.<BeginExecute>b__151_2(IAsyncResult asyncResult, Controller controller) +13
   System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +22
   System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +49
   System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +26
   System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.EndExecute(IAsyncResult asyncResult) +10
   System.Web.Mvc.<>c.<BeginProcessRequest>b__20_1(IAsyncResult asyncResult, ProcessRequestState innerState) +28
   System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +29
   System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +49
   System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +28
   System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +9
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +9873789
   System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step) +48
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +159

I am having the same issue when i update the version to 2.5.1.
Whichever RestSharp Version is the issue remains.
I am now using the EasyPost Version 2.3.1.4 and it is stable.

Revert your RestSharp version to 106.4.2

There was a change in the RestSharp Code for versions 106.5.x, see restsharp/RestSharp#1198

@att14 see this comment from RestSharp repo member restsharp/RestSharp#1198 (comment)

We have encounter the same issue in RestSharp 106.6.7 (on netcore 2.1). We are encountering it when trying to Verify an address but instead of a hard error - the address gets turned to null thus triggering a failure to find rates.

Any idea about when you can restore compatibility with the underlying library. Obviously this is pretty aggravating to paying customers of EasyPost.

@jim-at-survey-com

We are on the following versions:
.NET Framework: 4.7.2
EasyPost: 2.5.1
RestSharp: 106.6.7

We switched from EasyPost.Address.Verify to EasyPost.Address.CreateAndVerify to get around this issue.

FYI....the current issue and fix for me:

Targeting ASP.Net Standard 4.6.2
EasyPost 2.5.1
RestSharp 106.6.9

And getting the error:
Could not load file or assembly 'RestSharp, Version=106.4.2.0, Culture=neutral, PublicKeyToken=598062e77f915f75' or one of its dependencies. The system cannot find the file specified.

I have binding redirects set up to redirect versions 0 -> 106.6.9.... that didn't work..

I downgraded restsharp to 106.4.2 and changed the binding redirects to newVersion = 106.4.2. That works.

This is still an issue with the latest RestSharp. At the very least, the nuget package for EasyPost should target RestSharp (= 106.4.2) specifically, instead of "RestSharp (>= 106.4.2)" like it does right now.

att14 commented

How does that help? Do you have a reproducible Solution that I can test against? Whenever I create a new console application and import the library it works for me.

I have a working example in a large sln that I can't upload. But it is easily reproducable. As others have stated above, there were changes in RestSharp after v 106.4.2 that make the latest version of EasyPost not work. Details: restsharp/RestSharp#1198
If the EasyPost package won't allow an upgrade then you would have far fewer people running into this. At least until it's fixed in a newer version.

Any updates on this issue?

att14 commented

I have never been able to reproduce the problem. If someone can provide a Solution that reproduces the problem I can work on fixing it.

If you upgrade to the latest version of RestSharp, and try using the EasyPost libraries, you will see that it will fail because of the RestSharp version.

We've bumped the RestSharp version to 106.12.0. This change will be included in the next release of this library.

Hey there, I'm happy to announce we've released v2.6.0 which contains various updates including that update to RestSharp! You can download from Nuget here: https://www.nuget.org/packages/EasyPost-Official/

Great to hear.