Axapta Business Connector Logout problems

pedroparrapedroparra Member Posts: 58
edited 2008-04-10 in Dynamics AX
Hi all,

I am just testing the Business Connector because I need to make a interface
of Axapta with one .NET application.

Just only I started with this code:

Module Module1

Sub Main()
Dim Axapta As AxaptaCOMConnector.Axapta

Console.WriteLine("Testing Axapta Business Connector")
Try
Axapta = New AxaptaCOMConnector.Axapta
Axapta.Logon("pedro", "", "", "axaptaConfig")
Axapta.Logoff()
Axapta = Nothing
Catch ex As System.Exception
MsgBox("Error:" + ex.ToString, MsgBoxStyle.Exclamation,
"Application Error")
End Try

Console.WriteLine("Press key to finish")
Console.ReadLine()
End Sub

End Module


The first time I execute this code the user Logon in Axapta. But when the
application exits the user is still in the Online Users of my Axapta
installation. Futhermore, if I close manually the sessión of this user and I
try to execute this small application once more I get this Exception:

System.Runtime.InteropServices.COMException (0x80020009): Exception
occurred. at AxaptaCOMConnector.AxaptaClass.Logon(...)

Then I need to manually to restart the Navision Axapta Business Connector
COM+ component service in the Components services Window of Windows.

My installation is a Axapta v3 SP3. 3-Tier.
I executed the code in my Windows XP workstation.

Any ideas?

Thanks in advance.

Pedro

Comments

  • HarishHarish Member Posts: 172
    Hi Pedro,

    You cannot run your application once again without manually shutting down the first instance of Ax COM Connector.

    This is a well known behaviour documented in AxDvgCOMUs.chm. Please search for 'AXCOM.DLL' there.

    Hope this helps,
    Harish Mohanbabu
    Long way to go before I sleep..
  • pedroparrapedroparra Member Posts: 58
    Hi Harish,

    It seem that the user created by the Business Connector wont close it session until the Business Connector DLL isnt downloaded from memory.

    I have managed to solve the issue configuring to close the COM+ aplication "Navision Axapta Business Connector" after 0 minutes of innactivity (I can do this in its properties window).

    Also in during the logon process the user is already logged because the DLL hasnt unloaded I can unload the Navision Axapta Business Connector with this code:
    COMAdmin.COMAdminCatalog comCatalog = new COMAdmin.COMAdminCatalog();
                comCatalog.ShutdownApplication("Navision Axapta Business Connector");
                comCatalog.StartApplication("Navision Axapta Business Connector");
    

    For this code we need the COMAdmin.dll located at \windows\system32\com\comadmin.dll.

    Thank you
  • flo2005flo2005 Member Posts: 1
    pedroparra wrote:
    Hi all,

    I am just testing the Business Connector because I need to make a interface
    of Axapta with one .NET application.

    Just only I started with this code:

    Module Module1

    Sub Main()
    Dim Axapta As AxaptaCOMConnector.Axapta

    Console.WriteLine("Testing Axapta Business Connector")
    Try
    Axapta = New AxaptaCOMConnector.Axapta
    Axapta.Logon("pedro", "", "", "axaptaConfig")
    Axapta.Logoff()
    Axapta = Nothing
    Catch ex As System.Exception
    MsgBox("Error:" + ex.ToString, MsgBoxStyle.Exclamation,
    "Application Error")
    End Try

    Console.WriteLine("Press key to finish")
    Console.ReadLine()
    End Sub

    End Module

    Hello Pedro,

    I don't know if this will resolve anything (and my reply is certainly a little bit too late ;-) but you should really your code in order to prevent problems :
    Axapta.Logoff()
    Axapta = Nothing
    
    must be replaced by
    Try
    ...
    Catch ...
    ...
    Finally
        Axapta.Dispose()
    End Try
    
    This because the statement
    Axapta = Nothing
    
    does absolutely nothing (This behaviour is very different then with VB6). When Axapta is set to nothing, the instance will not directly finalized (and so Disposed) by the GC and this latency will cause sometimes quite ugly problems. Even if this might not help you personally, this might help anybody reading this code ;-)
    Cheers,
    Florian
Sign In or Register to comment.