[英]Method not found: 'System.Threading.Tasks.Task`1<!!0>
我正在使用 Microsoft Graph 应用程序来检索或创建 OneDrive 文件。 我上周做了一个 POC,一切都很顺利。
现在我尝试将我们的应用程序实现到现有的 MVC 网站中,但我收到了无法找到 System.Threading.Tasks.Task 的奇怪消息:
at Microsoft.Graph.DriveRequest.<GetAsync>d__6.MoveNext()
at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1.Start[TStateMachine](TStateMachine& stateMachine)
at Microsoft.Graph.DriveRequest.GetAsync(CancellationToken cancellationToken)
at Microsoft.Graph.DriveRequest.GetAsync()
at BizzMine.Data.Repositories.OnlineEditorRepo.OnlineEditorRepository.<RequestSuccess>d__10.MoveNext() in C:\Users\geertverthe\Documents\repos\bizzmine\BizzMine.Data.Repositories\OnlineEditorRepo\OnlineEditorRepository.cs:line 89
我怀疑对 System.Threading.Tasks 甚至 System.Web.Http 的绑定引用存在某种问题,但我不确定。
这是我使用的(简单)代码:
Drive myDrive = await _graphServiceClient.Me.Drive.Request().GetAsync();
我的 GraphServiceClient 是这样构造的:
_graphServiceClient = new GraphServiceClient(
new DelegateAuthenticationProvider(async (request) => {
request.Headers.Authorization = new AuthenticationHeaderValue("bearer", _tokens.AccessToken);
await Task.FromResult<object>(null);
}));
.NET 框架版本为4.6.1
我确实拥有正确的同意权限并且确实拥有有效的访问令牌。
关于我为什么会收到这种错误以及如何解决这个问题的任何想法?
非常感谢
经过大量尝试,我设法解决了我的问题。 由于我们的解决方案和项目包含许多 nuget 包,其中一个是 system.net.http。 显然,这带有 package NETStandard.Library.1.6.1。 我发现 system.net.http 的 nuget package 很奇怪,因为这只是在框架本身中。
在将 NETSTandard.Library.1.6.1 升级到最新版本后,我可以删除 system.net.http nuget 包。
在此之后我必须做的唯一更改是在缺少它的项目中引用 FRAMEWORK system.net.http 并在某些项目中删除过时的绑定重定向。
现在工作正常:-)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.