Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/325.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 访问ServiceAccountCredential C时未实现异常#_C#_Visual Studio 2015_Google Spreadsheet Api_X509certificate2_Notimplementedexception - Fatal编程技术网

C# 访问ServiceAccountCredential C时未实现异常#

C# 访问ServiceAccountCredential C时未实现异常#,c#,visual-studio-2015,google-spreadsheet-api,x509certificate2,notimplementedexception,C#,Visual Studio 2015,Google Spreadsheet Api,X509certificate2,Notimplementedexception,我有一个Windows应用程序,可以访问谷歌电子表格来创建电话簿。当我试图打开电话簿时,我被标记为System.NotImplementedException:该方法或操作未实现。我不确定原因,因为它似乎正在实现 这是第一个标记有问题的点: internal object FromCertificate(X509Certificate2 certificate) { throw new NotImplementedException(); //Error

我有一个Windows应用程序,可以访问谷歌电子表格来创建电话簿。当我试图打开电话簿时,我被标记为
System.NotImplementedException:该方法或操作未实现。
我不确定原因,因为它似乎正在实现

这是第一个标记有问题的点:

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#

我真的不知道为什么,因为它似乎正在实施

赠品如下:

throw new NotImplementedException();
抛出新的NotImplementedException()

它没有被实现,只是因为您使用
.FromCertificate(certificate)
从对象调用它。这只是调用方法,然后在其中运行代码。因此,它会点击你的
抛出新的NotImplementedException()代码-因此破坏等

实现你的方法,你需要删除
抛出新的NotImplementedException()并用您自己的逻辑替换它

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

internal object FromCertificate(X509Certificate2 certificate)
{
    // Do some work in here
}
希望这有帮助:)

只需添加“第二个点”标记异常的原因:方法中的
NotImplementedException
正在冒泡备份,调试器从调用它的点返回时会通知您。如果你向下处理(
catch
)它,除非你再次抛出(
throw
它),否则它不会冒出气泡