Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested answer

Process stops while validating ftp

(1) ShareShare
ReportReport
Posted on by 148

Hi,

While generating a retention receipt inside of an invoice journal the process stops in a method that validates the FTP

protected void validateFtp()
{
    object                          ftpo = null;
    System.Net.FtpWebRequest        request = null;
    System.Net.NetworkCredential    credential = null;
    System.Net.FtpWebResponse       response;
    ElectronicFTP                   electronicFTP = ElectronicFTP::find();
    ;
    try
    {
        ftpo = System.Net.WebRequest::Create(@"ftp://"   electronicFTP.FtpAddress);
        request = ftpo;
        credential = new System.Net.NetworkCredential(electronicFTP.UserName, electronicFTP.Passwd);
        request.set_Credentials(credential);
        request.set_Method("NLST");
        request.set_Proxy(System.Net.GlobalProxySelection::GetEmptyWebProxy());
        response = request.GetResponse(); //HERE IT STOPS
        request.Abort();
        response.Close();

    }
    catch
    {
        infolog.add(Exception::Error, "No se encuentra disponible el sitio Ftp");
        throw Exception::Error;
    }
}

If there is no response, why it didnt catch the error if it is inside a try catch. It doesn't pop any error message but it doesn't generate any retention receipt, it just doesn't do anything. What could be the problem here?

  • Daniel Mora Profile Picture
    148 on at
    RE: Process stops while validating ftp

    I do not have a ttsbegin / ttscommit where im callling the method validateFtp( ). I have the ttsbegin / ttscommit where I'm doing the query to select the specific document that I'm generating the retention.

  • ergun sahin Profile Picture
    8,816 Moderator on at
    RE: Process stops while validating ftp

    Do you have ttsBegin/Commit (at caller, etc)

  • Suggested answer
    Martin Dráb Profile Picture
    233,017 Most Valuable Professional on at
    RE: Process stops while validating ftp

    Are you saying that it doesn't get into the catch block at all?

    I would expect it does, you just don't do anything useful there. If you want to see the actual error, do something like this:

    rotected void validateFtp()
    {
        System.Net.WebRequest        	request;
        System.Net.NetworkCredential    credential;
        System.Net.FtpWebResponse       response;
        ElectronicFTP                   electronicFTP = ElectronicFTP::find();
        
        try
        {
            request = System.Net.WebRequest::Create(@"ftp://"   electronicFTP.FtpAddress);
            credential = new System.Net.NetworkCredential(electronicFTP.UserName, electronicFTP.Passwd);
            request.set_Credentials(credential);
            request.set_Method("NLST");
            request.set_Proxy(System.Net.GlobalProxySelection::GetEmptyWebProxy());
            response = request.GetResponse();
            response.Close();
        }
        catch (Exception::CLRError) 
        {
            throw error(AifUtil::getClrErrorMessage());
        }
    }

    By the way, your code

    infolog.add(Exception::Error, "No se encuentra disponible el sitio Ftp");
    throw Exception::Error;

    can  be simplified to mere

    throw error("No se encuentra disponible el sitio Ftp");

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Jonas ”Jones” Melgaard – Community Spotlight

We are honored to recognize Jonas "Jones" Melgaard as our April 2025…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 294,261 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 233,017 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,158 Moderator

Leaderboard

Product updates

Dynamics 365 release plans