Fetch the ip address of the system in AX:

Hi,
To fetch the IP address in AX use the below code,
static void fetchipaddress(Args _args)
{
System.String hostName = System.Net.Dns::GetHostName();
System.Net.IPHostEntry hostEntry = System.Net.Dns::GetHostEntry(hostName);
System.Net.IPAddress[] addresses = hostEntry.get_AddressList();
System.Net.IPAddress address;
System.Net.Sockets.AddressFamily addressFamily;
System.Collections.IEnumerator enumerator = addresses.GetEnumerator();

while (enumerator.MoveNext())
{
address = enumerator.get_Current();
addressFamily = address.get_AddressFamily();
if (addressFamily == System.Net.Sockets.AddressFamily::InterNetwork)
{
info(address.ToString());
}
}
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s