c# - YoutubeRequest实例化上的Null引用异常

标签 c# youtube gdata

我正在运行一个C#网络应用程序,其中包含将视频上传到youtube的功能。我正在为.NET使用gdata库。但是,当我在上传视频代码中点击此行时(在生成经过身份验证的请求的函数中)

YouTubeRequest req = new YouTubeRequest(sett);

我收到一个空引用异常,创建我的请求的完整功能如下:
public YouTubeRequest getReq()
{
        YouTubeRequestSettings sett = new YouTubeRequestSettings("Video-Postcard", devKey, consumerKey, consumerSecret, token, tokenSecret, "default", "video-postcard.com");
        YouTubeRequest req = new YouTubeRequest(sett);
        AsymmetricAlgorithm pk = getRsaKey();
        GAuthSubRequestFactory facto = new GAuthSubRequestFactory("youtube", "Video-Postcard");
        facto.PrivateKey = pk;
        facto.Token = token;
        req.Service.RequestFactory = (IGDataRequestFactory)facto;
        ((GDataRequestFactory)req.Service.RequestFactory).KeepAlive = false;
        ((GDataRequestFactory)req.Service.RequestFactory).Timeout = 360000;
        return req;
}

我使用同一段代码为搜索youtube的应用的不同部分生成请求,但是当我上传视频时,出现了异常。我已经搞砸了两天了,没有任何变化,有什么想法吗?

最佳答案

实例化devKey对象时,consumerKeyconsumerSecrettokentokenSecretYouTubeRequestSettings都为非空吗?

关于c# - YoutubeRequest实例化上的Null引用异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10424598/

相关文章:

ios - iPhone libxml2 undefined symbol (带有 gdata、kissxml、touchxml 等)

c# - 如何在无限循环中使用线程锁?

c# - 在不破坏封装的情况下创建对象

c# - 从 C# 中的原始 TCP 流获取 unicode 字符串

c# - 锁定main()线程

android - 在 Eclipse 中安装 GData API

iframe - Internet Explorer修复了YouTube嵌入定位问题

javascript - 创建 youtube 流 HTML5 的音频频谱

javascript - 将 div 悬停在 youtube 视频的顶部

java - 如何验证 Google Contacts API 的 Java 应用程序?