phungthaihoa / google-gdata

Automatically exported from code.google.com/p/google-gdata
0 stars 0 forks source link

Object reference not set to an instance of an object #597

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
this.youTubeAuthenticator = new ClientLoginAuthenticator(this.ApplicationName, 
ServiceNames.YouTube, this.credentials);

                this.youTubeAuthenticator.DeveloperKey = developerKey;

                YouTubeRequestSettings settings = new YouTubeRequestSettings(this.ApplicationName, developerKey, username, password);
                YouTubeRequest request = new YouTubeRequest(settings);

                settings.Timeout = ((GDataRequestFactory)request.Service.RequestFactory).Timeout = 60 * 60 * 1000;
                settings.Maximum = 2000000000;

                Video newVideo = new Video();
                String filename = Path.Combine(dir, _fileName);
                string contentType = MediaFileSource.GetContentTypeForFileName(filename);

                newVideo.YouTubeEntry.MediaSource = new MediaFileSource(filename, contentType);

                AtomLink link = new AtomLink("http://uploads.gdata.youtube.com/resumable/feeds/api/users/default/uploads");
                link.Rel = ResumableUploader.CreateMediaRelation;
                newVideo.YouTubeEntry.Links.Add(link);

                newVideo.Title = "title";

                newVideo.Tags.Add(new MediaCategory("Entertainment", YouTubeNameTable.CategorySchema));
                newVideo.Description = "Description";
                newVideo.YouTubeEntry.Private = true;
                newVideo.Keywords = "New Video";

                WebResponse response = this.ru.Insert(this.youTubeAuthenticator, newVideo.YouTubeEntry);

========== THE PROBLEM =============
The behavior is very strange. Debugging step-by-step with VS2008 the problem 
never happen. But running it straight ahead it throw an exception in this line 
(Object reference not set to an instance of an object):
newVideo.YouTubeEntry.Links.Add(link2);

or in this one if a I break before the Links.Add(link2):
ru.Insert(youTubeAuthenticator, newVideo.YouTubeEntry); (same exception)

Something related to the YouTubeEntry and the time I supossed. I put serveral 
Thread.Sleep´s thinking the time was the problem (time to instantiate 
something), but no luck to me.

Any idea?

Thanks for your help

Original issue reported on code.google.com by acr...@gmail.com on 8 Jun 2012 at 2:31

GoogleCodeExporter commented 8 years ago
Thanks for reporting the issue, it has been fixed in rev. 1198:

http://code.google.com/p/google-gdata/source/detail?r=1198

Original comment by ccherub...@google.com on 8 Jun 2012 at 9:19