Friday, January 24, 2014

Fetching IP address through X++

// Fetching IP address through X++ AX :


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());
    }
}
}

No comments:

Post a Comment

Copy Markup charges while posting purchase invoice using X++

 Copy Markup charges while posting purchase invoice using X++ Class: Important: Code logic is just for Reference.  New class => Duplicate...