FluentFTP Lib -> Auf bestimmten FTP Server weder Upload noch Download möglich NullReferenzException

  • C#

Es gibt 2 Antworten in diesem Thema. Der letzte Beitrag () ist von xChRoNiKx.

    FluentFTP Lib -> Auf bestimmten FTP Server weder Upload noch Download möglich NullReferenzException

    Halli Hallo,

    ich nutze die Lib: github.com/robinrodricks/FluentFTP
    Dort habe ich bei Issues schon ein ding offen weil ich denke es hat was mit der Lib zu tun
    ABER ich dachte ich frage jetzt hier trotzdem nochmal nach ob ich was falsch mache.

    Der Log/Ausgabe der Lib mit der Exception sieht so aus:
    Spoiler anzeigen

    Quellcode

    1. # OpenPassiveDataStream(PASV, "STOR /testfile", 0)
    2. Command: PASV
    3. Response: 227 Entering Passive Mode (xx,xx,xx,xxx,xx,xx,xxxx)
    4. Status: Connecting to xx.xx.xx.xx:36043
    5. Command: STOR /testfile
    6. Response: 150 Accepted data connection
    7. Status: FTPS Authentication Successful
    8. Status: Time to activate encryption: 0h 0m 0s. Total Seconds: 0,4012219.
    9. Ausnahme ausgelöst: "System.Net.Sockets.SocketException" in System.dll
    10. "xxxx.exe" (CLR v4.0.30319: xxxx.exe): "C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.resources\v4.0_4.0.0.0_de_b77a5c561934e089\System.resources.dll" geladen. Das Modul wurde ohne Symbole erstellt.
    11. Ausnahme ausgelöst: "System.IO.IOException" in System.dll
    12. Status: Disposing FtpSocketStream...
    13. Ausnahme ausgelöst: "System.Net.Sockets.SocketException" in System.dll
    14. Ausnahme ausgelöst: "System.IO.IOException" in System.dll
    15. Ausnahme ausgelöst: "System.ObjectDisposedException" in System.dll
    16. # OpenAppend("/testfile", Binary)
    17. # GetFileSize("/testfile")
    18. Command: SIZE /testfile
    19. Ausnahme ausgelöst: "System.NullReferenceException" in FluentFTP.dll
    20. Der Objektverweis wurde nicht auf eine Objektinstanz festgelegt.


    Der Code dazu:
    Spoiler anzeigen

    C#-Quellcode

    1. using (FtpClient conn = new FtpClient(Config.Default.FTPHost, Config.Default.FTPPort, Config.Default.FTPUser, Config.Default.FTPPassword))
    2. {
    3. conn.EncryptionMode = FtpEncryptionMode.Auto;
    4. conn.ValidateAnyCertificate = true;
    5. conn.SslProtocols = SslProtocols.Default | SslProtocols.Tls11 | SslProtocols.Tls12;
    6. conn.RetryAttempts = 3;
    7. conn.DataConnectionType = FtpDataConnectionType.PASV;
    8. conn.Connect();
    9. foreach (FileInfo file in files)
    10. {
    11. var result = conn.UploadFile(file.FullName, $"{Config.Default.FTPPath}{file.Name}", FtpRemoteExists.Overwrite, false, FtpVerify.Retry);
    12. if (result.IsFailure())
    13. {
    14. Console.WriteLine($"{file} not uploaded.");
    15. }
    16. }
    17. }​


    Die Exception kommt in Zeile 12 und sieht so aus:
    Spoiler anzeigen

    Quellcode

    1. ​Error while uploading the file to the server. See InnerException for more info
    2. bei FluentFTP.FtpClient.UploadFileInternal(Stream fileData, String localPath, String remotePath, Boolean createRemoteDir, FtpRemoteExists existsMode, Boolean fileExists, Boolean fileExistsKnown, Action`1 progress, FtpProgress metaProgress)
    3. bei FluentFTP.FtpClient.UploadFileFromFile(String localPath, String remotePath, Boolean createRemoteDir, FtpRemoteExists existsMode, Boolean fileExists, Boolean fileExistsKnown, FtpVerify verifyOptions, Action`1 progress, FtpProgress metaProgress)
    4. bei FluentFTP.FtpClient.UploadFile(String localPath, String remotePath, FtpRemoteExists existsMode, Boolean createRemoteDir, FtpVerify verifyOptions, Action`1 progress)
    5. System.NullReferenceException: Der Objektverweis wurde nicht auf eine Objektinstanz festgelegt.
    6. bei FluentFTP.FtpExtensions.IsKnownError(String reply, String[] strings)
    7. bei FluentFTP.FtpClient.GetFileSizeInternal(String path, FtpSizeReply sizeReply)
    8. bei FluentFTP.FtpClient.GetFileSize(String path)
    9. bei FluentFTP.FtpClient.OpenAppend(String path, FtpDataType type, Boolean checkIfFileExists)
    10. bei FluentFTP.FtpClient.UploadFileInternal(Stream fileData, String localPath, String remotePath, Boolean createRemoteDir, FtpRemoteExists existsMode, Boolean fileExists, Boolean fileExistsKnown, Action`1 progress, FtpProgress metaProgress)


    Irgendwas stimmt da nicht. Ich kann es mir nicht erklären. Es ist genau DER eine FTP Server bei dem es nicht klappt. Alle anderen die ich getestet habe da funktioniert alles einwandfrei.
    Habt ihr ne Idee? ?(
    Grüße , xChRoNiKx

    Nützliche Links:
    Visual Studio Empfohlene Einstellungen | Try-Catch heißes Eisen
    Keine Idee, aber da der Quellcode vorliegt könntest du dir eine pdb deiner verwendeten Version erzeugen und damit debuggen, oder halt einfach direkt den Quellcode fürs testen einbinden.

    Specify symbol (.pdb) and source files in the Visual Studio debugger (C#, C++, Visual Basic, F#)
    Danke für den Tipp. Da hätte ich ja auch selbst drauf kommen können.
    Den wirklichen Fehler habe ich nicht gefunden. Die Exception bekomme ich weg.
    Die kommt weil hier github.com/robinrodricks/Fluen…tils/FtpExtensions.cs#L40
    reply = null ist.
    Allerdings wenn ich da nen check vor setzte wenn null dann false ist die Datei wie jetzt auch zwar da auf dem FTP aber mit 0 byte.
    Grüße , xChRoNiKx

    Nützliche Links:
    Visual Studio Empfohlene Einstellungen | Try-Catch heißes Eisen