Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/281.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 为什么我会得到一个“a”;无法访问已处置的对象";尝试通过RingCentral SDK进行振铃呼叫时出错?_C#_Ringcentral_Ringout - Fatal编程技术网

C# 为什么我会得到一个“a”;无法访问已处置的对象";尝试通过RingCentral SDK进行振铃呼叫时出错?

C# 为什么我会得到一个“a”;无法访问已处置的对象";尝试通过RingCentral SDK进行振铃呼叫时出错?,c#,ringcentral,ringout,C#,Ringcentral,Ringout,我正在尝试使用他们的RingCentral SDK与RingCentral进行振铃通话。我基本上遵循他们在这里找到的教程: 除了我尝试在MVC web应用程序中而不是在控制台应用程序中执行此操作之外,我的代码基本上与他们的代码相同: public async Task<JsonResult> Call(string number) { var rc = new RestClient(RingCentralCredentials.ClientId, R

我正在尝试使用他们的RingCentral SDK与RingCentral进行振铃通话。我基本上遵循他们在这里找到的教程:

除了我尝试在MVC web应用程序中而不是在控制台应用程序中执行此操作之外,我的代码基本上与他们的代码相同:

    public async Task<JsonResult> Call(string number)
    {
        var rc = new RestClient(RingCentralCredentials.ClientId, RingCentralCredentials.ClientSecret, false);
        var tokenInfo = await rc.Authorize(RingCentralCredentials.Username, RingCentralCredentials.Extension, RingCentralCredentials.Password);
        // The above line throws the exception.
        var parameters = new MakeRingOutRequest();
        parameters.from = new MakeRingOutCallerInfoRequestFrom { phoneNumber = RingCentralCredentials.Username };
        parameters.to = new MakeRingOutCallerInfoRequestTo { phoneNumber = number };
        parameters.playPrompt = false;
        var resp = await rc.Restapi().Account().Extension().RingOut().Post(parameters);
        return Json(resp.status, JsonRequestBehavior.AllowGet);
    }
有人对此有什么建议吗?我使用的SDK版本是1.2.1:


本教程中的原始应用程序是一个控制台应用程序。你能用控制台应用程序重现这个问题吗?或者这只是一个web应用程序问题? 我看到你打开了一个RingCentral支持案例。我会回答你的支持情况。一旦我们找到根案例,我将在这里发布更新


更新:我已经尝试了Marko提供的示例代码,我想我已经找到了根本原因。当我们试图通过密码进行授权时,正在使用的RingCentral应用程序不允许密码流。有关此问题的详细信息:

本教程中的原始应用程序是一个控制台应用程序。你能用控制台应用程序重现这个问题吗?或者这只是一个web应用程序问题? 我看到你打开了一个RingCentral支持案例。我会回答你的支持情况。一旦我们找到根案例,我将在这里发布更新


更新:我已经尝试了Marko提供的示例代码,我想我已经找到了根本原因。当我们试图通过密码进行授权时,正在使用的RingCentral应用程序不允许密码流。有关此问题的更多信息:

我认为可能是-在调用此代码之前,您在某个地方有一个
RingCentralCredentials.Close()
或类似的名称?@KenY-N如果您指的是我上面使用的RingCentralCredentials,它是一个静态类,只包含凭据的静态属性——基本上是硬编码值ClientId、ClientSecret等。该类上没有Close()方法。除了我在问题中包含的代码之外,我没有任何其他与RingCentral相关的代码。我想可能是-在调用此代码之前,您在某个地方有a
RingCentralCredentials.Close()
或类似的代码?@KenY-N如果您指的是我在上面使用的RingCentralCredentials,它是一个静态类,只包含凭据的静态属性——基本上是硬编码值ClientId、ClientSecret等。该类上没有Close()方法。除了我在问题中包含的代码之外,我没有任何其他与RingCentral相关的代码。
Cannot access a disposed object.
Object name: 'System.Net.Http.FormUrlEncodedContent'.
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.ObjectDisposedException: Cannot access a disposed object.
Object name: 'System.Net.Http.FormUrlEncodedContent'.