I am trying to open an Ax instance using C# in a different RDP Environment(Remote Desktop) to read labels from AOT using Logon(Company,Language,Object Server,Configuration) ,but to no success till now.
Does anybody know how to go about this problem ?
The code is given below.
class Program { [
STAThread]
staticvoid Main(string[] args) {
Axapta ax;
string AxConfig;
string sID = "@SYS21669";
object o;
bool b;
AxConfig =
@"TST2_USR";
try
{
// Login to Microsoft Dynamics Ax.
ax =
newAxapta();
ax.Logon("xyz", "en-us","V1-SDAX-02",AxConfig); }
catch (Exception e) {
Console.WriteLine("An error occurred in object creation or Axapta logon: {0}", e.Message);
return ;
}
// Logon was successful.
try
{
// Call a static class method.
// In this example, call SysLabel::labelId2String2
// to determine the label string for a particular label ID.
o = ax.CallStaticClassMethod(
"SysLabel", "labelId2String2" , sID); }
catch (Exception e)
{
Console.WriteLine("An error has been encountered during CallStaticClassMethod: {0}",e.Message);
b = ax.Logoff();
return;
}
// Display the returned string.
Console.WriteLine("The label string for {0} is {1}.", sID, o.ToString());
Console.WriteLine("Press any key to continue.");
Console.ReadLine();
// Log off from Microsoft Dynamics AX.
b = ax.Logoff();