MissingMethodException


M

Mark Hudson

Hi All,
I'm writing a simple C#.NET CF app for a UDP Client/Server.. and I'm getting
a weird MissingMethodException in my class. It's weird because I can call
every other method in the class, except this one.. I've even tried renaming
it!
Have I missed something glaringly obvious?

objUDP = new Comms.UDP();

objUDP.IsConnected(); // I can Step-Into thess
function no problems... no matter what order I call them
objUDP.BytesReceived();
objUDP.BytesSent();
objUDP.GetLocalHost();
objUDP.GetLocalHostList(); // Crashes on this line here - it wont
even Step Into the code behind!


Hope you can help - thanks in advance...
Mark


PS: Go Australia in the Rugby World Cup! (www.rugbyworldcup.com)
 
Ad

Advertisements

M

Mark Hudson

This may be useful.. althought I can never even reach this when stepping
through.
Note I was trying to return a string[] thinking there may be a bug.. now
it's just returning a string and still doesn't work?
MH


public string GetLocalHostList()

{

IPAddress[] IPList;

string IPListString;

int i;

try

{

IPHostEntry localHostEntry = Dns.GetHostByName(Dns.GetHostName());

IPList = localHostEntry.AddressList;

//IPListString = new string[IPList.Length];

IPListString = "";

for (i=0;i<IPList.Length; i++)

{

IPListString += System.Text.Encoding.ASCII.GetString(
IPList.GetAddressBytes());

if (i < IPList.Length) IPListString += ",";

//IPListString.SetValue( System.Text.Encoding.ASCII.GetString(
IPList.GetAddressBytes()), i);

}

return IPListString;

}

catch

{

// return Loopback address

//string[] ReturnString = { Encoding.ASCII.GetString(
IPAddress.Loopback.GetAddressBytes()) };

//return ReturnString;

return Encoding.ASCII.GetString( IPAddress.Loopback.GetAddressBytes());

}

}
 
M

Mark Hudson

Following extensive debugging, I found that the IPAddress.GetAddressBytes()
method is not supported in the .NET CF.

Surely since the compiler knows it is targetting a CE device it could raise
at least a warning that a given method is not supported, rather than leaving
it to a rather unhelpful MissingMethodException at run-time?

Perhaps that given there was a Desktop app using the full Framework, in the
same solution, it got a bit confused? BUG?

*sigh*

Mark
 
C

Chris Tacke, eMVP

It could also be a case where the CF supports it, but the underlying device
doesn't have support for it (strange in this case).

-Chris
 
Ad

Advertisements

M

Mark Hudson

Thanks Chris - indeed it is a Compaq ipaq 3970, not even a year old!

I have since read other posts with the same problem... it seems the run-time
MissingMethodException is somewhat misleading to the novice. I wont make
that mistake again :)

Mark
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top