Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

System.TimeoutException not caught

(1) ShareShare
ReportReport
Posted on by 41

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
    41 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
    232,978 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

🌸 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,217 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 232,978 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,158 Moderator

Leaderboard

Product updates

Dynamics 365 release plans