web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

How to dispose Axapta object

(0) ShareShare
ReportReport
Posted on by 130

Hi All,

I am creating a new custom MVC application  which will pull data from Dynamics Ax using BC. For improving the performance of the site , I stored the Axapta object  created (after axapta.LogOn()) in session variable so that I can reuse the object in the subsequent calls in a browsing session. Then when a user opens  a new window it creates a new session of Axapata and store it in .Net Session variable. 

The issue is that when a user closes the browser , I will not be able to dispose the object inside session since I don't have any control over window close.

So the connection to Ax persists even though the user is idle for more than 20 mins since the worker process is still running. The connection will be closed if the Application pool recycles since it will unload the unmanaged objects from memory. 

Could you please guide me so that  I can handle this situation.

*This post is locked for comments

I have the same question (0)
  • Martin Dráb Profile Picture
    236,394 Most Valuable Professional on at
    RE: How to dispose Axapta object

    Axapta class has Logoff() method - it should close the connection. You could call it by yourself, or you can call it automatically when the session ends (Session_OnEnd). You can configure timeout when sessions expires.

  • gokul731@hotmail.com Profile Picture
    130 on at
    RE: How to dispose Axapta object

    Thanks for the comments Martin.

    But in the case of our production environment , we have a web farm with load balancing enabled. We will not be able to use InProc mode of session in this case since the session has to be shared across the servers. Session_OnEnd will fire only when the mode is InProc.

  • Martin Dráb Profile Picture
    236,394 Most Valuable Professional on at
    RE: How to dispose Axapta object

    Okay, you're probably right. Nevertheless you already know what to do with AX. Details about implementation/configuration in ASP.NET is something what you should rather discuss in a forum about ASP.NET.

  • nav Profile Picture
    180 on at
    RE: How to dispose Axapta object

    Maybe the following will help

    axbytes.blogspot.co.uk/.../wcf-worker-session-inactivity-timeout.html

    Its for WCF worker sessions.

  • Martin Dráb Profile Picture
    236,394 Most Valuable Professional on at
    RE: How to dispose Axapta object

    Also try to set Automatic shutdown in user options in AX. If it works, it will be the simplest solution.

  • Dick Wenning Profile Picture
    8,705 Moderator on at
    RE: How to dispose Axapta object

    ore just remove some object?

    blogs.msdn.com/.../1-the-garbage-collector-in-x-and-the-clr.aspx

  • Martin Dráb Profile Picture
    236,394 Most Valuable Professional on at
    RE: How to dispose Axapta object

    That's the problem described above - the reference is held by the session, therefore the object will never be destroyed (until recycling the pool).

    You're right that if Axapta class implements Dispose() correctly, it's not strictly necessary to call Logoff(), although it's still highly recommended. But that's just a detail in this case.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Community Member Profile Picture

Community Member 4

#1
Martin Tocauer Profile Picture

Martin Tocauer 4

#3
Nayyar Siddiqi Profile Picture

Nayyar Siddiqi 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans