【发布时间】:2016-04-06 18:59:54
【问题描述】:
我正在使用 C# 并使用 YouTube V3 API。我正在尝试在视频中插入评论,但是每当我这样做时,我都会收到 "{"Object reference not set to an instance of an object."}" 的异常,每当我运行类似于上述代码的任何内容时都会发生这种情况:
public void AddComment()
{
CommentThread commentToAdd = new CommentThread();
commentToAdd.Snippet.IsPublic = true;
commentToAdd.Snippet.TopLevelComment.Snippet.TextOriginal = "Test";
commentToAdd.Snippet.VideoId = "kc-LBxBcyG8";
commentToAdd.Snippet.TopLevelComment.Snippet.VideoId = "kc-LBxBcyG8";
CommentThreadsResource.InsertRequest ins = JKYouTube.NewYouTubeService().CommentThreads.Insert(commentToAdd, "snippet");
var insertedComment = ins.Execute();
}
我将此与谷歌资源管理器进行比较并使用相同的属性,并且资源管理器实际上在我的程序失败的地方添加了 cmets。 https://developers.google.com/youtube/v3/docs/commentThreads/insert
一到代码的第二行
commentToAdd.Snippet.IsPublic = true;
上面的每一行都会出错并继续。
任何帮助将不胜感激。
【问题讨论】:
-
您正在使用
Snippet对象上的设置器。你确定Snippet不是null?
标签: c# youtube-api