版本与RestSharp冲突 [英] Version Conflict with RestSharp

查看:227
本文介绍了版本与RestSharp冲突的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好我正在尝试将我的类库从版本2.0更新到4.5.2以及我的旧库使用RestSharp.Net2参考,并且在将我的库更新为4.5.2时我收到以下错误 


请提供任何帮助,在此先感谢...


错误日志: 


'RestSharp.Net2,Version = 102.7.0.0,Culture = neutral,PublicKeyToken = e179d1049b315bf3'和'mscorlib,Version = 4.0.0.0,Culture = neutral,
PublicKeyToken = b77a5c561934e089'



这是我的调用代码:


private
无效 CallAsyncInternal< T >(IRestRequest
请求,操作< RestResponse< T>>回调,


< span style ="font-size:9.5pt; font-family:Consolas; color:black">            frmRetryHandler theForm,
int retryNumber = 0)
其中 T:
()


        {


           
如果 (retryNumber> = frmRetryHandler.MaxRetries)


            {


               
抛出
TimeoutException( $"无法成功
调用方法'
{TheClient.BuildUri(request)} '重试10次后。" );


           }



           
如果 (! this .IsHandleCreated)


            {


               
this 。CreateHandle();


           }



            TheClient.ExecuteAsync(request,(RestResponse< T> response)=>


             {


&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;
<跨度style ="font-size:9.5pt; font-family:Consolas; color:blue"> try


&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; {


    ;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&N BSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;
if (response.StatusCode == 0)


&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; &NBSP; {


  &NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;
throw
new TimeoutException( $" ;请求
{TheClient.BuildUri(request)} 超时。" );


&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; }


  &NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;回调(响应);


&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; }


  &NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;
catch (TimeoutException)


               {


  &NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;
if (theForm._owner ==
null ||!theForm.IsHandleCreated)


            &NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; {


  &NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;
throw ;


                    }



&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; &NBSP;&NBSP;&NBSP; theForm.BeginInvoke( new
System.Action(()=>


&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP ;    {


&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP ;
using var
overlay =
BackgroundMask(theForm._owner,theForm))


&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP ; {


&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP ;    
如果 (overlay.ShowMaskedDialogBox()== DialogResult.Retry)


&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP ;    
{


&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP ;        
TheClient.Timeout = GetNewTimeoutTime(retryNumber);


&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP ;        
CallAsyncInternal< T>(request,callback,theForm,retryNumber + 1);


< p style ="text-autospace:none"> &NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP ;        
返回 ;


&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP ;    
}


&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP ;    
抛出
TimeoutException( $"用户取消
异步服务调用
{request.Resource} 。" );


&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP ;}


&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;}));



           });


       }




解决方案

您是否尝试过
'private void CallAsyncInternal< T>(...,RestSharp.Net2.Action< RestResponse< T>>回调,... )'






Hi I'm trying to update my Class library from version 2.0 to 4.5.2 and my old library using RestSharp.Net2 reference also and i'm getting below error when update my library to 4.5.2 

Any help please , Thanks in Advance...

Error Log: 

The type 'Action' exists in both 'RestSharp.Net2, Version=102.7.0.0, Culture=neutral, PublicKeyToken=e179d1049b315bf3' and 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'

Here is my calling Code:

private void CallAsyncInternal<T>(IRestRequest request, Action<RestResponse<T>> callback,

            frmRetryHandler theForm, int retryNumber = 0) where T : new()

        {

            if (retryNumber >= frmRetryHandler.MaxRetries)

            {

                throw new TimeoutException($"Unable to successfully call method '{TheClient.BuildUri(request)}' after 10 retries.");

            }

            if (!this.IsHandleCreated)

            {

                this.CreateHandle();

            }

            TheClient.ExecuteAsync(request, (RestResponse<T> response) =>

            {

                try

                {

                    if (response.StatusCode == 0)

                    {

                        throw new TimeoutException($"Request to {TheClient.BuildUri(request)} timed out.");

                    }

                    callback(response);

                }

                catch (TimeoutException)

                {

                    if (theForm._owner == null || !theForm.IsHandleCreated)

                    {

                        throw;

                    }

                    theForm.BeginInvoke(new System.Action(() =>

                    {

                        using (var overlay = new BackgroundMask(theForm._owner, theForm))

                        {

                            if (overlay.ShowMaskedDialogBox() == DialogResult.Retry)

                            {

                                TheClient.Timeout = GetNewTimeoutTime(retryNumber);

                                CallAsyncInternal<T>(request, callback, theForm, retryNumber + 1);

                                return;

                            }

                            throw new TimeoutException($"User cancelled asynchronous service call to {request.Resource}.");

                        }

                    }));

                }

            });

        }


解决方案

Have you tried ‘private void CallAsyncInternal<T>(…, RestSharp.Net2.Action<RestResponse<T>> callback, …)’?




这篇关于版本与RestSharp冲突的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆