• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3592
  • Last Modified:

Dynamics AX 2012 Business Connector logon from VB.NET

I'm trying to log on to AX 2012 using Business Connector, but I'm getting an error.

I have added the reference to the Microsoft.Dynamics.BusinessConnectorNet.dll

Here's the code:
Imports System
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Data
Imports System.Drawing
Imports System.Text
Imports System.Windows.Forms

Imports BC = Microsoft.Dynamics.BusinessConnectorNet

Public Class Form1

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  Dim strTemp As String = ""

  Dim AXapta As BC.Axapta
  Dim custTable As BC.AxaptaRecord
  Dim bcProxyCredentials As System.Net.NetworkCredential
    AXapta = New BC.Axapta
    bcProxyCredentials = New System.Net.NetworkCredential("axbc", "password", "ourdomain.local")
    AXapta.LogonAs("axbc", "ourdomain.local", bcProxyCredentials, "CEU", "en-us", "", "TESTAX")
    'AXapta.Logon("", "", "", "")
  Catch ex As System.Exception
  End Try

End Sub
End Class

Here's the error:

System.IO.FileLoadException: A procedure imported by 'Microsoft.Dynamics.AX.ManagedInteropCore32.dll' could not be loaded.
File name: 'Microsoft.Dynamics.AX.ManagedInteropCore32.dll'
   at Microsoft.Dynamics.BusinessConnectorNet.Axapta.LogonAs(String user, String domain, NetworkCredential bcProxyCredentials, String company, String language, String objectServer, String configuration)
   at WindowsApplication1.Form1.Button1_Click(Object sender, EventArgs e) in C:\Documents and Settings\c\AX\Development\VB\BCTester\BCTester\Form1.vb:line 42


axbc user is:
part of ourdomain (active directory)
has the roles: BusinessConnector and System Administrator set up in AX 2012

I'm using Visual Basic Express 2010 with target set to Net 4.0.
Windows XP PRO SP3
  • 4
  • 3
1 Solution
-How did you install the Business Connector ?
-I recommend to run the same code on Windows 7 PC, you might find it works ok (due to support for new security protocols that are not supported on XP)
-Try to use .NET 3.5 instead of .NET 4
ETdudeAuthor Commented:
I didn't personally install it. It was done by a partner. We have set up a proxy user with BusinessConenctor role.

I have tried to switch to 3.5, but I'm getting the same error. Microsoft suggested to use 4.0 as the target.

I think I have found a culprit. Microsoft.Dynamics.AX.ManagedInteropCore32.dll is calling some functions from advapi32.dll that are shown in red when using dependency walker.
These are functions: EnableTraceEx, EventRegister, EventUnregister, EventWrite.
I'm using the latest version 5.1.2600.5512 of advapi32.dll that came with Service Pack 3 for XP.

Finally I have tried the same code on Windows 7 machine and it worked right away. I wish I could develop on XP Pro though.
Hello ETdude,

Based on your findings which indicate that the Business Connector works fine on your Win 7 but not on Win XP and my past experience with integrating with Dynamics AX, I recommend to use the AX AIF (Application Integration Framework).
This approach is the one recommended by Microsoft - http://dynamics-ax.blogspot.com/2011/05/net-business-connector-not-recommend.html

When using AIF (requires separate AX license on server side), you can access AX from clients using WCF and MSMQ. I recommend to use AIF WCF Services. Developing .NET WCF client code can be done on your Windows XP SP3.
Refer to Microsoft AX documentation at http://msdn.microsoft.com/en-us/library/cc652581.aspx which includes details and sample C# code (you can use VB.NET as well).

Good luck
Microsoft Certification Exam 74-409

VeeamĀ® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

ETdudeAuthor Commented:
Do you now if I can access the AX services using VB6?
We have a lot of integration I have developed using VB6 for our current ERP (we will switch to AX next year) and would be happy not to convert them all to vb.net.
You can communicate between VB6 and AX AIF "File system exchange" adaptor using XML files.
Refer to Microsoft Dynamics AX AIF configuration white paper
ETdudeAuthor Commented:
It's a general advice without specifics and the most difficult part is to know details.
I am realy surprised. You could have asked for more details instead of closing the question with such low rating.

Featured Post

Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now