Main Site Documentation

EnableDynamicDns() - Exception


#1

I need little help. When I try use EnableDynamicDns() I get exception:


 #### Exception System.NotSupportedException - CLR_E_NOT_SUPPORTED (1) ####
    #### Message: 
    #### Microsoft.SPOT.Net.NetworkInformation.NetworkInterface::UpdateConfiguration [IP: 0000] ####
    #### Microsoft.SPOT.Net.NetworkInformation.NetworkInterface::EnableDynamicDns [IP: 000f] ####
    #### PEPP.Network::EnableDynamicDns [IP: 000a] ####
    #### PEPP.Network+LAN::Connect [IP: 0078] ####
    #### PEPP.Network::.ctor [IP: 01fb] ####
    #### PEPP.Module::InitNetwork [IP: 000c] ####
    #### PEPP.Module::.ctor [IP: 005f] ####
    #### PEPP.PEPP::Main [IP: 0020] ####
A first chance exception of type 'System.NotSupportedException' occurred in Microsoft.SPOT.Net.dll

Code which I use:


public bool Connect()
            {
                try
                {
                    Log.WriteDebugLog("Network.LAN.Connect() - Start.");
                    if (!Ethernet.IsEnabled)
                    {
                        Ethernet.Enable();
                    }
                    netif = NetworkInterface.GetAllNetworkInterfaces();

                    if (!Ethernet.IsCableConnected)
                    {
                        Log.WriteDebugLog("Network.LAN.Connect() - Cable is not connected!");
                        return false;
                    }
                    else
                    {
                        Log.WriteDebugLog("Network.LAN.Connect() - Cable Connected.");
                        if (DHCP)
                        {
                            //DHCP Enabled
                            if (!Network.IsDhcpEnabled())
                                Network.EnableDhcp();
                            else
                                Network.RenewDhcpLease();
                        }
                        else
                        {
                            //DHCP Disabled
                            Network.EnableStaticIP(IPAddress, SubnetMask, GatewayAddress);
                            
                            if (DynamicDNS)
                            {
                                //Dynamic DNS Enabled
                                Network.EnableDynamicDns();
                            }
                            else
                            {
                                //Dynamic DNS Disabled
                                Network.EnableStaticDns(DNSAddress);
                            }
                        }

                        lan_network.CurrentIPAddress = Network.IPAddress();
                        lan_network.CurrentSubnetMask = Network.SubnetMask();
                        lan_network.CurrentGatewayAddress = Network.GatewayAddress();
                        lan_network.CurrentDNSAddress = Network.DnsAddresses();
                        
                        network_is_read = true;
                        return true;
                    }                    
                }
                catch (Exception e)
                {
                    Log.WriteErrorLog("Network.LAN.Connect() - ERROR:" + e.Message);
                    return false;
                }
            }


When I call:
Network.EnableDynamicDns();
It call other function which EnableDynamicDns on NetworkInterface:


public static void EnableDynamicDns()
        {
            try
            {
                netif[0].EnableDynamicDns();
            }
            catch { }
        }

All other things work ok only EnableDynamicDns do not work… Any idea why?


#2

Maybe it is not supported? I don’t know what dynamic DNS is… Do you? :slight_smile:


#3

Certainly sounds redundant whatever it is :wink:


#4

I know what this mean on normal computers :slight_smile: On PC is this like Automatic Get DNS :slight_smile:
When you use DHCP you automatic get IP, MASK, GATEWAY and DNS.
When you use static IP you must manualy set IP, MASK, GATEWAY but for DNS you have two option:
1.)Use Static DNS:


netif[0].EnableStaticDns(new string[] {"8.8.8.8", "4.4.4.4"});

2.) Use Dynamic DNS:


netif[0].EnableDynamicDns();

First option work ok but second do not work. Both are in .NETMF documentation under “Microsoft.SPOT.Net.NetworkInformation” -> “NetworkInterface Class” -> “NetworkInterface Methods”


#5

I don’t think Dynamic DNS is supported


#6

@ Joe: If is not supported why is then in Microsoft .NETMF Documentation?


#7

I think this is true not only with NETMF. it is true even with most networking devices, Correct me if I am wrong:

[ulist]With DHCP, you can use it to get dynamic network settings including DNS server address, or you can use the dynamic network settings and set a static DNS server IP address.[/ulist]

[ulist]With static network settings, everything should be static.[/ulist]

You can try it now on your PC if you like. Try to set static IP to the network adapter with dynamic DNS.

Probably:

  1. To enable back the dynamic dns settings to dhcp settings after using static dns with DHCP.
  2. Several NETMF C# calsses or methods are there but not necessarily fully supported (some times they only stubs which provide only the skeleton of the class). It is there just to insure a generic interface that fits any possible solution. For example Wireless8011 class is there and documented. But this does not mean that WiFi is supported on all NETMF device.

At the end, my answer comes from my own experience. I might be wrong. You can post the question at netmf.com.


#8

By definition, your network can provide DHCP addresses or you can provide them yourself. If you use DHCP, then you can optionally provide DNS addresses from the DHCP server. If you do not use DHCP then you have no “dynamic” source of DNS, so you MUST provide name server addresses if you want to resolve names.

So the code as you had it in post 1 should not work, even if Dynamic DNS is supported - you would need to structure your checks differently. If DHCP check needs to also check if dynamic or static DNS; the ELSE then just needs to check the static DNS address exists and apply.

that doesn’t answer the question about whether it’s supported or not though…


#9

@ Joe: You are right. Im move EnableDynamicDns() to static IP configuration because on DHCP has produce same thing…
Now I use:


if (DHCP)
{
    //DHCP Enabled
    if (!Network.IsDhcpEnabled)
        Network.EnableDhcp();
    else
        Network.RenewDhcpLease();

    if (DynamicDNS)
    {
        //Dynamic DNS Enabled
        if (!Network.IsDynamicDnsEnabled)
            Network.EnableDynamicDns();
        //Dynamic DNS Disabled
        else
            Network.EnableStaticDns(DNSAddress);
    }
}

And still receive errors:


 #### Exception System.NotSupportedException - CLR_E_NOT_SUPPORTED (9) ####
    #### Message: 
    #### Microsoft.SPOT.Net.NetworkInformation.NetworkInterface::UpdateConfiguration [IP: 0000] ####
    #### Microsoft.SPOT.Net.NetworkInformation.NetworkInterface::EnableDynamicDns [IP: 000f] ####
    #### PEPP.Network::EnableDynamicDns [IP: 000a] ####
    #### PEPP.Network+LAN::Connect [IP: 0065] ####
    #### PEPP.Network::.ctor [IP: 00b6] ####
    #### PEPP.Module::StartNetworkModule [IP: 000d] ####
A first chance exception of type 'System.NotSupportedException' occurred in Microsoft.SPOT.Net.dll