最后的建议是@Vincent所说的,如果您可以访问SDK代码,则也可以尝试使其适应UWP.这意味着您需要修改此SDK的源代码. I am attempting to use Google Drive as a storage location in my UWP application. I started at the quickstart provided by Google. I copy the code into a blank UWP project, change some of the output code (Console.Writeline to a textbox.append method) and I try to build it. It fails to build and reports the error:Cannot find type System.ComponentModel.ExpandableObjectConverter in module System.dllI am running Windows 10 and VS 2015 and I have installed the sdk through NuGet. The example code in the quickstart does work in a console application. It is the UWP application that is having issues.For the UWP application, I put the quickstart code in a button click method. This was because the API actually has an async method for the uwp apps which is a bit different then the code given in the quickstart.Includes:using System;using System.Collections.Generic;using System.IO;using Windows.UI.Xaml;using Windows.UI.Xaml.Controls;using Google.Apis.Auth.OAuth2;using Google.Apis.Drive.v3;using Google.Apis.Drive.v3.Data;using Google.Apis.Services;using Google.Apis.Util.Store;using System.Threading;The Button Method:private async void button_Click(object sender, RoutedEventArgs e) { UserCredential credential; using (var stream = new FileStream("client_secret.json", FileMode.Open, FileAccess.Read)) { string credPath = ""; //System.Environment.GetFolderPath( //System.Environment.SpecialFolder.Personal); credPath = Path.Combine(credPath, ".credentials/drive-dotnet-quickstart.json"); credential = await GoogleWebAuthorizationBroker.AuthorizeAsync( new Uri("ms-appx:///Assets/client_secrets.json"), Scopes, "user", CancellationToken.None); //Console.WriteLine("Credential file saved to: " + credPath); } // Create Drive API service. var service = new DriveService(new BaseClientService.Initializer() { HttpClientInitializer = credential, ApplicationName = ApplicationName, }); // Define parameters of request. FilesResource.ListRequest listRequest = service.Files.List(); listRequest.PageSize = 10; listRequest.Fields = "nextPageToken, files(id, name)"; // List files. IList<Google.Apis.Drive.v3.Data.File> files = listRequest.Execute() .Files; textBox.Text += "Files:\n"; if (files != null && files.Count > 0) { foreach (var file in files) { textBox.Text += (file.Name + file.Id + "\n"); } } else { textBox.Text += ("No files found."); } }The test code will not work once the app is compiled as it is missing the code to load the client secret. Since I have not been able to test the code, this is all I can provide.There is another post that is semi-related except that the answer is just that it wont work and the post has been dead for 4 years. I also wanted to create a new post that tags the google team specifically (like the quickstart says to do).My specific question is: Is there a work around to this issue or am I just doing this wrong? 解决方案 I agree with @Vincent, UWP apps use COM as a base and builds from there. Not all .Net API can be used in UWP apps, this SDK is based on .Net APIs, this is why your console app is OK, but your UWP app is down. For the differences between them, here is a great answer which explain this issue. But,I just tried to search for this without any luck, but here is a suggestion, you can use JavaScript to make request to the Drive API. To do this, you can refer to JavaScript Quickstart. Then you can turn it to a web hosted UWP app, for more information, you can refer to Convert your web application to a Universal Windows Platform (UWP) app.Another suggestion which can probably make the work easier is using Rest API to send HTTP requests, you can also refer to API Reference.The final suggestion which is as @Vincent said, if you have access to the SDK code, you can also try to adapt it for UWP. It means you need to modify the source code of this SDK. 这篇关于在UWP App中使用Google Drive .NET API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!