代码之家  ›  专栏  ›  技术社区  ›  TeoVr81

启动时Xamarin Android FTP身份验证问题

  •  0
  • TeoVr81  · 技术社区  · 7 年前

    我正在用Xamarin用C语言开发一个Android应用程序。 在这个应用程序中,我需要一个在设备启动后启动的服务,并在FTP服务器中上载文件。 如果我使用按钮单击操作启动此服务,所有功能正常,但如果我使用BroadcastReceiver并截获BOOT_COMPLETED事件以启动FTP连接,我会收到以下错误:

    ex.Message: The authentication or decryption has failed.
    ex.StackTrace: at System.Net.FtpWebRequest.EndGetRequestStream (System.IAsyncResult asyncResult)
                   at System.Net.FtpWebRequest.GetRequestStream ()
                   at TestProject.FTPUtility.upload (System.String userName, System.String password, System.String sourceFile, System.String targetFile)
    

    我不明白为什么只有在服务启动时才收到身份验证或解密错误。我还试图在ping成功后才启动连接(等待设备internet连接),但没有任何更改。

    1 回复  |  直到 7 年前
        1
  •  0
  •   TeoVr81    7 年前

    System.Net.ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };