首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Google Calendar在托管服务器上失败,但在本地主机上工作

Google Calendar在托管服务器上失败,但在本地主机上工作
EN

Stack Overflow用户
提问于 2021-04-09 05:18:43
回答 1查看 24关注 0票数 0

这一直运行得很好。有一天,我开始在没有对生产服务器上的代码进行任何更改的情况下获得以下代码。它仍然可以在本地主机上工作:

代码语言:javascript
运行
复制
using (var stream =
               new FileStream(System.Web.Hosting.HostingEnvironment.MapPath("~/App_Data/GoogleCalendar/client_secret.json"), FileMode.Open, FileAccess.Read))
            {
                //string credPath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal);
                string credPath = System.Web.Hosting.HostingEnvironment.MapPath("~/App_Data/");
                credPath = Path.Combine(credPath, ".credentials/calendar-dotnet-quickstart.json");
          
                credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
                    GoogleClientSecrets.Load(stream).Secrets,
                    Scopes,
                    "user",
                    CancellationToken.None,
                    new FileDataStore(credPath, true)).Result;
               // Console.WriteLine("Credential file saved to: " + credPath);
            }

分配凭据时出现以下错误:

代码语言:javascript
运行
复制
System.AggregateException: One or more errors occurred. ---> System.ComponentModel.Win32Exception: Application not found at System.Diagnostics.Process.StartWithShellExecuteEx(ProcessStartInfo startInfo) at System.Diagnostics.Process.Start() at System.Diagnostics.Process.Start(ProcessStartInfo startInfo) at Google.Apis.Auth.OAuth2.LocalServerCodeReceiver.d__6.MoveNext() in C:\Apiary\v1_19\google-api-dotnet-client\Src\Support\GoogleApis.Auth.DotNet4\OAuth2\LocalServerCodeReceiver.cs:line 86 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Google.Apis.Auth.OAuth2.AuthorizationCodeInstalledApp.d__8.MoveNext() in C:\Apiary\v1_19\google-api-dotnet-client\Src\Support\GoogleApis.Auth\OAuth2\AuthorizationCodeInstalledApp.cs:line 77 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Google.Apis.Auth.OAuth2.GoogleWebAuthorizationBroker.d__4.MoveNext() in C:\Apiary\v1_19\google-api-dotnet-client\Src\Support\GoogleApis.Auth.DotNet4\OAuth2\GoogleWebAuthorizationBroker.cs:line 134 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Google.Apis.Auth.OAuth2.GoogleWebAuthorizationBroker.d__1.MoveNext() in C:\Apiary\v1_19\google-api-dotnet-client\Src\Support\GoogleApis.Auth.DotNet4\OAuth2\GoogleWebAuthorizationBroker.cs:line 60 --- End of inner exception stack trace --- at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions) at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification) at System.Threading.Tasks.Task`1.get_Result() at CFRA_MVC.Core.GoogleCalendar..ctor() ---> (Inner Exception #0) System.ComponentModel.Win32Exception (0x80004005): Application not found at System.Diagnostics.Process.StartWithShellExecuteEx(ProcessStartInfo startInfo) at System.Diagnostics.Process.Start() at System.Diagnostics.Process.Start(ProcessStartInfo startInfo) at Google.Apis.Auth.OAuth2.LocalServerCodeReceiver.d__6.MoveNext() in C:\Apiary\v1_19\google-api-dotnet-client\Src\Support\GoogleApis.Auth.DotNet4\OAuth2\LocalServerCodeReceiver.cs:line 86 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Google.Apis.Auth.OAuth2.AuthorizationCodeInstalledApp.d__8.MoveNext() in C:\Apiary\v1_19\google-api-dotnet-client\Src\Support\GoogleApis.Auth\OAuth2\AuthorizationCodeInstalledApp.cs:line 77 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Google.Apis.Auth.OAuth2.GoogleWebAuthorizationBroker.d__4.MoveNext() in C:\Apiary\v1_19\google-api-dotnet-client\Src\Support\GoogleApis.Auth.DotNet4\OAuth2\GoogleWebAuthorizationBroker.cs:line 134 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Google.Apis.Auth.OAuth2.GoogleWebAuthorizationBroker.d__1.MoveNext() in C:\Apiary\v1_19\google-api-dotnet-client\Src\Support\GoogleApis.Auth.DotNet4\OAuth2\GoogleWebAuthorizationBroker.cs:line 60<--- 
EN

回答 1

Stack Overflow用户

发布于 2021-04-09 23:25:47

我已经替换了它们所在的json文件和文件夹,似乎修复了它。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/67012020

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档