Install AxCom.dll
- Run D:\Setup.exe HideUI=1 AcceptLicenseTerms=1 InstallComBusinessConnector=1 if it is failed, find AxCom.dll from installation and copy the file into C:\Program Files (x86)\Microsoft Dynamics AX\50\Client\Bin.
- Register AxCom.dll by regSvr32 in command prompt.
- Create axCom class.
- Create method getName.
Name getName(Name _name)Create a C# Console program (Just a sample)
{
;
return strfmt("-- %1 --",_name);
}
- Add reference to AxCom.dll, in tab COM, select Axapta Com Connector 1.2 Type Library.
- C# code.
using System.Collections.Generic;
using System.Linq;
using System.Text;
using AxaptaCOMConnector;//AX Business Connector
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Axapta3 ax = new Axapta3();
IAxaptaObject axObj;
string axName;
AxaptaParameterList list = new AxaptaParameterList();
String name;
name = "Default Name";
//axCOM.Logon("CEU", "", "", "");
ax.LogonAs("axService", "DAX", "axProxy", "DAX", "Password");//log on as AxService user in DAX domain over on proxy user. Add parameters as needed.
axObj = ax.CreateObject("axCom", null, null, null, null, null, null);//create object from axCom class in AX
name = System.Console.ReadLine();//get name from console
//create parameter
list.Size=1;
list.set_Element(1, name);
axName = (string)axObj.CallEx("getName", list);//execute method in axCom class
System.Console.WriteLine(axName);//show modified name in console
System.Console.ReadKey();//wait until hit a key
ax.Logoff();//log out
}
}
}