Google api 谷歌云C API从不回调

Google api 谷歌云C API从不回调,google-api,google-cloud-storage,Google Api,Google Cloud Storage,我正在使用以下代码访问我的存储: private static IConfigurableHttpClientInitializer GetInstalledApplicationCredentials() { string serviceAccountEmail = "xxxxxxxx"; X509Certificate2 certificate; using (Stream stream = new FileStream(Path.Combine(AppDomain.CurrentDoma

我正在使用以下代码访问我的存储:

private static IConfigurableHttpClientInitializer GetInstalledApplicationCredentials()
{
string serviceAccountEmail = "xxxxxxxx";

X509Certificate2 certificate;
using (Stream stream = new FileStream(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "App_Data", "path.p12"), FileMode.Open, FileAccess.Read))
{
    using (MemoryStream ms = new MemoryStream())
    {
        stream.CopyTo(ms);
        certificate = new X509Certificate2(ms.ToArray(), "notasecret", X509KeyStorageFlags.Exportable);
    }
}

ServiceAccountCredential credential = new ServiceAccountCredential(
    new ServiceAccountCredential.Initializer(serviceAccountEmail)
    {
        Scopes = new[] {
            StorageService.Scope.DevstorageFullControl
    },
}.FromCertificate(certificate));

return credential;
}

        private static StorageService GetStoreageService()
    {
        var service = new StorageService(
            new BaseClientService.Initializer()
            {
                HttpClientInitializer = GetInstalledApplicationCredentials(),
                ApplicationName = "app"
            }
        );

        return service;
    }

public static byte[] DownloadAudio(string fileName)
    {
        var service = GetStoreageService();

        var req = service.Objects.Get(bucketName, fileName);
        var readobj = req.Execute();

        var downloader = new MediaDownloader(service);

        using (var ms = new MemoryStream())
        {
            downloader.Download(readobj.MediaLink, ms);

            return ms.ToArray();
        }
    }
在var readobj=req.Execute行中;我的应用程序只是阻塞,从未给我回复。我已经尝试过JSON和OAuth。唯一的区别是,在IIS Express中使用OAuth可以工作,但在IIS Express之外则不行。使用P12或JSON,我在IIS或IIS Express中都遇到了问题

有什么想法吗

谢谢,,
Murilo不确定这是否是问题所在,但请尝试

certificate = new X509Certificate2(keyFilePath, "notasecret", X509KeyStorageFlags.MachineKeySet | X509KeyStorageFlags.Exportable);

谢谢你的回复。这不是问题所在,问题是一些调用使用了.Result并导致了死锁。我把所有的呼叫都改为使用wait,它成功了。非常感谢你