Using .NET Business Connector, you can access Microsoft Dynamics AX data or business logic from a .NET-connected application.
To add a reference to .NET Business Connector
•Open Visual Studio.
•In Solution Explorer, right-click References and select Add Reference.
•In the Add Reference window, select the Browse tab.
•Specify the location of Microsoft.Dynamics.BusinessConnectorNet.dll, and then click Add.
Add code to call a Microsoft Dynamics AX method in Visual Studio C#.
using System;
using Microsoft.Axapta.BusinessConnector;
namespace AXMethodCall
{
class Class1
{
static void Main(string[] args)
{
// Create the .NET Business Connector objects.
Axapta ax;
object o;
bool b;
try
{
// Login to Microsoft Dynamics Ax.
ax = new Axapta();
ax.Logon(null, null, null, null);
}
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.
o = ax.CallStaticClassMethod("Class Name ", "Method Name",Argument);
}
catch (Exception e)
{
Console.WriteLine("An error has been encountered during CallStaticClassMethod: {0}", e.Message);
b = ax.Logoff();
return;
}
// Log off from Microsoft Dynamics AX.
b = ax.Logoff();
}
}
}
Thursday, August 7, 2008
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment