Reputation: 301
im making a website who uses the Dynamics AX Business Connector to connect with AX, it´s working fine but sometimes the users don´t logout.
Here is my code:
Microsoft.Dynamics.BusinessConnectorNet.Axapta DynAx = new Microsoft.Dynamics.BusinessConnectorNet.Axapta();
try
{
DynAx.Logon(null, null, null, null);
//Execute some methods
DynAx.Logoff();
}
catch (Exception ex)
{
DynAx.Logoff();
}
and in ax i can see the users logged in. Again this happens sometimes, thats why i don´t know who may be. Maybe Dispose() Method it's better?.
Thank you for taking your time to read this.
Upvotes: 0
Views: 717
Reputation: 11564
Logon/logoff works for me correctly, but if you're saying sometimes it doesn't, then the reason is most likely one of the following:
//Execute some methods
section could be locking or preventing the logoff.In my AX2012R3 environment I can run the below PowerShell
code over and over with success. This points me towards one of the above as a cause.
Add-Type -Path "C:\Program Files\Microsoft Dynamics AX\60\BusinessConnector\Bin\Microsoft.Dynamics.BusinessConnectorNet.dll"
$ax = new-object Microsoft.Dynamics.BusinessConnectorNet.Axapta
$ax.logon($null, $null, $null, $null)
$b = $ax.CreateAxaptaRecord("userinfo")
$array = New-Object System.Collections.ArrayList
$b.ExecuteStmt("select id from %1")
while($b.found){
$array.add($b.get_field("id")) | out-null
$b.next() | out-null
}
$array | Format-Table -AutoSize
$ax.Logoff()
$ax.Dispose()
Upvotes: 2