Business Connector .NET - AX4 - how does Logon choose a config?

Hello -

  • I am trying to call a job from C# .NET and am not seeing the behaviour I was thinking of.
  • I would like to call the AX job frmo a .NET program to run periodially on a schedule, but not using AX Batch.
  • It seems so simple that I’m not sure what I am missing.

A. When I use this one (null for server and config) , it works, but I cannot tell which config it is choosing. (somewhere in the registry?)

ax.Logon(“100”, “en-us”, null, null);

B. When I use this style it seems to ignore the config file and again, just use some default.

AxConfig = @"\AXSERVER\AxConfigs\AX4TEST.axc";

ax.Logon(“100”, “en-us”, “myobjectserver”, AxConfig);

Perhaps the correct answer is just to use the Business Connector Proxy.

However, either way I need to specify which config to use.

Question 1 : when using “Logon” how does it choose the AX config to use?

Question 2: Does the proxy use up an AX license - I.e. require a dedicated AX user account?

Thanks for any guidance you can provide.

Don

using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Dynamics.BusinessConnectorNet;

namespace Mynamespace
{
class RunAxJob
{
static void Main(string[] args)
{
Axapta ax;
String AxConfig, AxJob;

AxConfig = @"\AXSERVER\AxConfigs\AX4TEST.axc";

AxJob = “MyAxJob”;

ax = new Axapta();
try
{
ax.Logon(“100”, “en-us”, “myobjectserver”, AxConfig);
// ax.Logon(“100”, “en-us”, null, null);
}
catch (Exception)
{
Console.WriteLine(“Exception occurred during logon: {0}”, AxConfig);
}
Console.WriteLine(“Start - run AX job: {0}”,AxJob);
try
{
ax.CallJob(AxJob);
}
catch (Exception myException)
{
Console.WriteLine(“Exception occurred during job call”);
Console.WriteLine(myException.Message);
}

Console.WriteLine(“Press any key to continue”);
Console.ReadKey(); // pause the console for unser input

ax.Logoff();
}
}
}

Hello,

The BC settings get stored in the registry. For more, refer to this technet article - http://technet.microsoft.com/en-us/library/aa569654.aspx

Here is a small code example for the LogOn method


Microsoft.Dynamics.BusinessConnectorNet.Axapta DynAx;
DynAx = new Microsoft.Dynamics.BusinessConnectorNet.Axapta();
System.Net.NetworkCredential nc = new System.Net.NetworkCredential(“ProxyUserId”, “password”);
DynAx.LogonAs(Environment.UserName,“FullyQualifiedDomainName”,nc,“dat”, “en-us”," company1@AOS:2713",“AXClient”);
DynAx.LogonAs(Environment.UserName,“FullyQualifiedDomainName”,nc,“dat”,“en-us”,“company1@AOS:2713”,“c:\Client.axc”);


NOTE - two backslashes are missing in your path specification.

Regards,