1

我有一个访问 Google 电子表格以创建电话簿的 Windows 应用程序。当我尝试打开电话簿时,我被标记为System.NotImplementedException: The method or operation is not implemented.我不太确定为什么,因为它似乎正在实施?

这是第一个被标记为问题的地方:

internal object FromCertificate(X509Certificate2 certificate)
        {
            throw new NotImplementedException(); //Error flags this line
        }

这是第二个。据我所知,这部分没有问题,但它仍然在标记异常。

ServiceAccountCredential credential = new ServiceAccountCredential(
           new ServiceAccountCredential.Initializer(serviceAccountEmail)
           {
               Scopes = new[] { "https://www.googleapis.com/auth/spreadsheets", "https://docs.google.com/feeds" }
           }.FromCertificate(certificate));

任何建议将不胜感激。我在 Visual Studio 2015 中使用 C#。

4

1 回答 1

1

我不太确定为什么,因为它似乎正在实施?

赠品是这里的这一行:

throw new NotImplementedException();

存根方法时,通常throw new NotImplementedException()是Visual Studio 的样板。

它没有被实现,只是因为你从对象中调用它.FromCertificate(certificate)。这只是调用方法,然后运行其中的代码。因此,它然后会命中您的throw new NotImplementedException();代码 - 从而破坏等。

实现您的方法,您需要删除throw new NotImplementedException();并用您自己的逻辑替换它。

您需要在FromCertificate()方法中添加一些代码:

internal object FromCertificate(X509Certificate2 certificate)
{
    // Do some work in here
}

希望这可以帮助 :)

于 2016-06-20T23:14:38.320 回答