我有一个C#应用程序,应该在我的YouTube频道上传文件视频,所以我写了以下代码:
public static string UploadVideo(string FilePath, string Title, string Description)
{
YouTubeRequestSettings settings;
YouTubeRequest request;
string devkey = "myApiKei";
string username = "mail@gmail.com";
string password = "password";
settings = new YouTubeRequestSettings(" ", devkey, username, password) { Timeout = -1 };
request = new YouTubeRequest(settings);
Video newVideo = new Video();
newVideo.Title = Title;
newVideo.Description = Description;
newVideo.Private = true;
newVideo.YouTubeEntry.Private = false;
newVideo.YouTubeEntry.MediaSource = new MediaFileSource(FilePath, "video/mp4");
Video createdVideo = request.Upload(newVideo);
return createdVideo.VideoId;
}
我不知道我的申请名称是什么
settings = new YouTubeRequestSettings(" ", devkey, username, password) { Timeout = -1 };
所以当我尝试运行应用程序时,几分钟后,我收到了这个错误:
System.Windows.Markup.XamlParseException verificata
_HResult=-2146233087
_message='La chiamata del costruttore sul tipo 'yOUtUBE.MainWindow' corrispondente ai vincoli di associazione specificati ha generato un'eccezione.' numero riga '3' e posizione riga '9'.
HResult=-2146233087
IsTransient=false
Message='La chiamata del costruttore sul tipo 'yOUtUBE.MainWindow' corrispondente ai vincoli di associazione specificati ha generato un'eccezione.' numero riga '3' e posizione riga '9'.
Source=PresentationFramework
LineNumber=3
LinePosition=9
StackTrace:
in System.Windows.Markup.WpfXamlLoader.Load(XamlReader xamlReader, IXamlObjectWriterFactory writerFactory, Boolean skipJournaledProperties, Object rootObject, XamlObjectWriterSettings settings, Uri baseUri)
InnerException: System.Net.WebException
_HResult=-2146233079
_message=Richiesta annullata: Richiesta annullata..
HResult=-2146233079
IsTransient=false
Message=Richiesta annullata: Richiesta annullata..
Source=System
StackTrace:
in System.Net.ConnectStream.CloseInternal(Boolean internalCall, Boolean aborting)
in System.Net.ConnectStream.System.Net.ICloseEx.CloseEx(CloseExState closeState)
in System.Net.ConnectStream.Dispose(Boolean disposing)
in System.IO.Stream.Close()
in Google.GData.Client.GDataGAuthRequest.CopyRequestData()
in Google.GData.Client.GDataGAuthRequest.Execute(Int32 retryCounter)
in Google.GData.Client.GDataGAuthRequest.Execute()
in Google.GData.Client.MediaService.EntrySend(Uri feedUri, AtomBase baseEntry, GDataRequestType type, AsyncSendData data)
in Google.GData.Client.Service.Insert(Uri feedUri, AtomEntry newEntry, AsyncSendData data)
in Google.GData.Client.Service.Insert[TEntry](Uri feedUri, TEntry entry)
in Google.GData.YouTube.YouTubeService.Upload(String userName, YouTubeEntry entry)
in Google.YouTube.YouTubeRequest.Upload(String userName, Video v)
in Google.YouTube.YouTubeRequest.Upload(Video v)
in yOUtUBE.MainWindow.UploadVideo(String FilePath, String Title, String Description) in c:\Users\michele.castriotta\Documents\Visual Studio 2013\Projects\yOUtUBE\yOUtUBE\MainWindow.xaml.cs:riga 59
in yOUtUBE.MainWindow..ctor() in c:\Users\michele.castriotta\Documents\Visual Studio 2013\Projects\yOUtUBE\yOUtUBE\MainWindow.xaml.cs:riga 28
InnerException: System.IO.IOException
_HResult=-2146232800
_message=Impossibile chiudere il flusso prima che siano stati scritti tutti i byte.
HResult=-2146232800
IsTransient=false
Message=Impossibile chiudere il flusso prima che siano stati scritti tutti i byte.
Source=System
StackTrace:
in System.Net.ConnectStream.CloseInternal(Boolean internalCall, Boolean aborting)
InnerException:
有人可以建议我,问题出在哪里?