访问ServiceAccountCredential C#时出现NotImplementedException [英] NotImplementedException when Accessing ServiceAccountCredential C#

查看:101
本文介绍了访问ServiceAccountCredential C#时出现NotImplementedException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have a Windows app that access a Google spreadsheet to create a phone book. When I try to open the phone book, I get flagged with System.NotImplementedException: The method or operation is not implemented. I'm not really sure why, because it seems like it is being implemented?

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

This is the first spot that's being flagged with the issue:

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

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

This is the second. As far as I can tell, there's nothing wrong with this part but it's still flagging an exception.

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#.

Any suggestions would be really appreciated. I'm using C# with Visual Studio 2015.

推荐答案

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

I'm not really sure why, becayse it seems like it is being implemented?

赠品是此行:

throw new NotImplementedException();

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

The throw new NotImplementedException() is usually boiler-plate from Visual Studio when stubbing out methods.

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

It isn't being implemented, just because you're calling it from the object with .FromCertificate(certificate). This is just calling the method, which then runs the code within it. Ergo, it then hits your throw new NotImplementedException(); code - thus breaking etc.

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

To implement your method, you need to remove the throw new NotImplementedException(); and replace it with your own logic.

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

You will need to add some code in your FromCertificate() method:

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

希望这会有所帮助:)

这篇关于访问ServiceAccountCredential C#时出现NotImplementedException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆