views:

111

answers:

2

I am using OpenNetCF 2.3.0.39 and I am getting a hard crash when try to access the DnsAddresses.Count property. Is anyone familiar with this problem or a workaround?

Dim interfaces As NetworkInterface() = NetworkInterface.GetAllNetworkInterfaces()

For Each ni As NetworkInterface In interfaces

Dim ipProps As IPInterfaceProperties = ni.GetIPProperties()

If ipProps.DnsAddresses.Count > 0 Then

...

A: 

Did yo find the answer to this as I have the same problem

Jamie
No, I never found a solution for this. The work around that I used was to place the code in a try catch. If I get an exception then I just can't use the values.
t-boy
A: 

Hi,

I'm also experiencing this problem.

It's a Motorola MC75 with WinMo 6.1 Pro. I'm using VS2008 and OpenNETCF 2.3.0.39. I've factory reset the device and just deployed the software. On this line:

if(oProps.DnsAddresses.Count == 1)

The application bombs out and VS reports loss of connection. No exception is trappable.

Using .NET Reflector it fail in:

From IPInterfaceProperties

internal unsafe void RefreshPerAdapterInfo()
{
  int pOutBufLen = 0;
  if (this.m_dnsList != null)
  {
    this.m_dnsList.Changed -= new AddressChangedHandler(this.m_dnsList_Changed);
    this.m_dnsList.InternalClear();
  }
  NativeMethods.GetPerAdapterInfo(this.m_info.Index, null, ref pOutBufLen);
  byte[] buffer = new byte[pOutBufLen];
  fixed (byte* numRef = buffer)
  {
    byte* pPerAdapterInfo = numRef;
    NativeMethods.GetPerAdapterInfo(this.m_info.Index, pPerAdapterInfo, ref pOutBufLen);
    this.m_autoConfigEnabled = *(((int*) pPerAdapterInfo)) != 0; //THIS IS THE LINE THAT FAILS.
    pPerAdapterInfo += 4;
    this.m_autoConfigActive = *(((int*) pPerAdapterInfo)) != 0;
    pPerAdapterInfo += 8;
    this.m_dnsList = (IPAddressCollection) IPUtility.ParseAddressesFromPointer(pPerAdapterInfo, this.m_info.AdapterName);
    this.m_dnsList.Changed += new AddressChangedHandler(this.m_dnsList_Changed);
  }
}

The bolded line is the line that fails if you step over it:

this.m_autoConfigEnabled = (((int) pPerAdapterInfo)) != 0;

It should be bolded in the code as well, then again it might end up with some *s around it. Sorry, never used stackoverflow before.

Any, Chris, I hope you're reading this! :)

Regards,

James.

RoboJ1M
I'll see what I can find.
ctacke

related questions