我正在尝试使用我的C#应用程序中的网站上提供的最新youtube sdk将视频(mp4)上传到youtube,但是我看到应用程序抛出了outofMemory异常,我使用以下代码。
string username = "myemail@gmail.com";
string password = "password";
service.setUserCredentials(username, password);
service.QueryClientLoginToken();
YouTubeRequestSettings yousettings = new YouTubeRequestSettings("my app", devkey, username, password);
YouTubeRequest yourequest = new YouTubeRequest(yousettings);
string feedUrl = "http://gdata.youtube.com/feeds/api/users/default";
ProfileEntry profile = (ProfileEntry)yourequest.Service.Get(feedUrl);
Console.WriteLine("Username : " + profile.UserName);
Video newVideo = new Video();
//Video createdVideo = new Video();
newVideo.Title = "MyTestMovie";
newVideo.Tags.Add(new MediaCategory("Autos", YouTubeNameTable.CategorySchema));
newVideo.Keywords = "cars, funny";
newVideo.Description = "My description";
newVideo.YouTubeEntry.Private = false;
newVideo.Tags.Add(new MediaCategory("mydevtag, anotherdevtag", YouTubeNameTable.DeveloperTagSchema));
//newVideo.YouTubeEntry.Location = new GeoRssWhere(37, -122);
// alternatively, you could just specify a descriptive string
newVideo.YouTubeEntry.setYouTubeExtension("location", "Alabama, USA");
newVideo.YouTubeEntry.MediaSource = new MediaFileSource("e:\\Auroville.mp4", "video/mp4");
//yourequest.ke
Video cretedVideo = yourequest.Upload(newVideo);
我收到以下异常
捕获了System.OutOfMemoryException消息=类型异常 抛出'System.OutOfMemoryException'。来源= mscorlib程序
堆栈跟踪: 在System.IO.MemoryStream.set_Capacity(Int32值) 在System.IO.MemoryStream.EnsureCapacity(Int32值) 在System.IO.MemoryStream.Write(Byte []缓冲区,Int32偏移量,Int32计数) 在System.IO.BinaryWriter.Write(Byte []缓冲区,Int32索引,Int32计数) at Google.GData.Client.Service.WriteInputStreamToRequest(Stream input,Stream output) at Google.GData.Client.MediaService.EntrySend(Uri feedUri,AtomBase baseEntry,GDataRequestType type,AsyncSendData data) at Google.GData.Client.Service.Insert(Uri feedUri,AtomEntry newEntry,AsyncSendData data) 在Google.GData.Client.Service.Insert [TEntry](Uri feedUri,TEntry条目) at Google.GData.YouTube.YouTubeService.Upload(String userName,YouTubeEntry entry) at Google.YouTube.YouTubeRequest.Upload(String userName,Video v) 在Google.YouTube.YouTubeRequest.Upload(视频v) at TesterApp.Form1.button1_Click(Object sender,EventArgs e)位于C:\ Users \ user \ Dropbox \ Build \ TesterApp \ TesterApp \ Form1.cs:第66行
的InnerException:
有没有解决方案?
答案 0 :(得分:0)
这在.NET客户端库的问题跟踪器条目中得到解决:http://code.google.com/p/google-gdata/issues/detail?id=512