Raptor Networking "This should never happen"

I am working on Raptor with the ENC28 network interface. I believe I am using the latest codebase (see versions at the end of the message).
I am attempting to get a DHCP connection, in this case to a corporate network. Estabilshing the connection works (gets IP address <> around half the time on the first try. I have coded this to repeatedly try until it connects. This code, executing the function EstabilshNetwork the SECOND time if it did not connect the first time will fail on the line ethernet_ENC28.Interface.Open giving the error
DHCP=True, but no connection
#### Exception System.Exception - 0x00000000 (5) ####
#### Message: NetworkEventFlags: This should never happen!
#### GHI.Premium.Net.NetworkChangeExtension::OnNetworkChangeCallback [IP: 0067] ####
#### GHI.Premium.Net.NetworkChangeExtension+NetworkChangeExtensionListener::OnEvent [IP: 000d] ####
#### Microsoft.SPOT.EventSink::EventDispatchCallback [IP: 0014] ####
A first chance exception of type ‘System.Exception’ occurred in GHI.Premium.Net.dll

This is similar to what was reported here: https://www.ghielectronics.com/community/forum/topic?id=14802&page=1#msg149755
but I did not see a resolution…

Suggestions are appreciated.

Imports GT = Gadgeteer
Imports GTM = Gadgeteer.Modules
Imports Gadgeteer.Modules.GHIElectronics
Imports Gadgeteer.Modules.Seeed
Imports Microsoft.SPOT.Hardware
Imports GHI.Hardware.G400
Imports System
Imports System.Net
Imports System.Collections
Imports Microsoft.SPOT
Imports GHI.Premium.Net
Imports GHI.Premium.Net.EthernetENC28J60
Imports System.Text
Imports System.Threading
Imports Microsoft.SPOT.Net.NetworkInformation
Imports System.Net.Sockets
Imports GHI.Premium.Hardware.LowLevel

Namespace GadgeteerApp1
    Partial Public Class Program

        Private Shared server As Socket

        Dim WithEvents InternetTimer As GT.Timer = New GT.Timer(100)

        Private Shared useDHCP As Boolean = True
        Private useWebPage As Boolean = False

        '        Private Shared baro As PTmonitor

        Public Sub ProgramStarted()

            Debug.Print("Program Started")
            'baro = New PTmonitor(barometer, 0)

            char_Display.PrintString("Starting Network")

            While EstablishNetwork() = False
                char_Display.SetCursor(1, 0)
            End While
            char_Display.SetCursor(1, 0)
            char_Display.PrintString("IP:" & ethernet_ENC28.Interface.NetworkInterface.IPAddress.ToString)
        End Sub

        Private Function EstablishNetwork() As Boolean
            If ethernet_ENC28.Interface.IsOpen Then
            End If
            With ethernet_ENC28.Interface
                Debug.Print("Cable connected = " & .IsCableConnected.ToString)
                Debug.Print("activated = " & .IsActivated.ToString)
                If useDHCP Then
                    .NetworkInterface.RenewDhcpLease() ' no clue if this is needed, or if this hurts
                    .NetworkInterface.EnableStaticIP("", "", "")
                End If

            End With

            If ethernet_ENC28.Interface.NetworkInterface.IPAddress = "" Then
                Debug.Print("DHCP=" & ethernet_ENC28.Interface.NetworkInterface.IsDhcpEnabled.ToString & ", but no connection " & ethernet_ENC28.Interface.NetworkInterface.IPAddress.ToString)
                Return False
            End If

            Return True

        End Function

Assembly: GTM.GHIElectronics.Display_HD44780 ( Attaching deployed file.
Assembly: RaptorNetServer ( Attaching deployed file.
Assembly: Gadgeteer ( Attaching deployed file.
Assembly: GTM.GHIElectronics.Ethernet_ENC28 ( Attaching deployed file.
Assembly: Microsoft.VisualBasic ( Attaching deployed file.
Assembly: System ( Attaching deployed file.
Assembly: GHI.Premium.IO ( Attaching deployed file.
Assembly: GTM.GHIElectronics.UsbClientDP ( Attaching deployed file.
Assembly: GHI.Premium.Net ( Attaching deployed file.
Assembly: GHIElectronics.Gadgeteer.FEZRaptor ( Attaching deployed file.
Assembly: Gadgeteer.SPI ( Attaching deployed file.
Assembly: GHI.Hardware.G400 ( Attaching deployed file.
Assembly: GTM.Seeed.Barometer ( Attaching deployed file.
Assembly: Microsoft.SPOT.Net ( Attaching deployed file.
Assembly: GHI.Premium.Hardware ( Attaching deployed file.
Assembly: GHI.Premium.System ( Resolving.

I think some one already reported this. Seach the forum for “ows me a beer” or similar.

@ Reinhard - Yes, I had noted that but as I mentioned I did not see a resolution. I was also hoping for a beer ???
A workaround would be appreciated if one exists…

The problem I had was with opening a previously closed interface as that caused it to choke and spew the message in question. What I was trying to do was a pseudo reset of the network interface.

@ Duke Nuken: Thanks for the reply — how did you solve the problem??? Around half the time I connect using DHCP, and half the time I do not…

@ rockybooth,

I am not sure if .Close() actually performs the Dispose as it is usually the case.

Try .Dispose() right after the .Close().

I noticed that you are using .NET Gatgeteer, I hope the .Dispose() method doesn’t exist in there as it does for the plain GHI Premium NETMF.

Check my comments in the related link you mentioned: https://www.ghielectronics.com/community/forum/topic?id=14802&page=1#msg152340