Skip to main content

Notifications

Announcements

No record found.

Finance | Project Operations, Human Resources, ...
Answered

System.TimeoutException not caught

Posted on by 35

Hello,

I'm calling a WCF service by using this X code:

             // Use the AifUtil class to create an instance of the service client object.
            searchClient = AifUtil::CreateServiceClient(clientType);

The code is working, but yesterday I received a System.TimeoutException because the remote WCF service was not reachable.

This is the stacktrace (sorry, it's an image):

crash.png

What puzzles me is that exception should have been caught, since my code is:

    try
    {
        //Construct and configure the service client by retrieving the X   type for the service and using the AifUtil class
        
        clientType = CLRInterop::getType('FAB_CrifIntegrationV2.ServiceReference.SearchClient');

        // Use the AifUtil class to create an instance of the service client object.
		searchClient = AifUtil::CreateServiceClient(clientType);
		searchResponse = searchClient.CompanySearch(m_username, m_password, guid2str(transactionGuid), null, searchData,
													byRef inquiryDetails, byRef companyList);

		// ...
    }
    catch (Exception::CLRError)
    {
        // Handle the exception and display message in the InfoLog.
        ex = CLRInterop::getLastException();
        error(ex.ToString());

        // ...
    }

As per my understanding of MS Dynamics documentation, catching CLRError is exactly for this cases (i.e. exceptions thrown by CLR objects) but System.TimeoutException seems to have by-passed it.

Can you advise, please?

  • Simone F Profile Picture
    Simone F 35 on at
    RE: System.TimeoutException not caught

    Yes, unfortunately I wasn't aware of this X++ behaviour. Thank you for pointing it.

  • Verified answer
    Martin Dráb Profile Picture
    Martin Dráb 230,235 Most Valuable Professional on at
    RE: System.TimeoutException not caught

    Isn't your catch clause inside a database transaction? If so, it's ignored and execution continues after the transaction. That's where you can catch the exception.

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans