I have recently starting developing with VS2005, Windows Mobile 5.0 and the CF 2.0.
I have noticed that recently I am receiving a NotSupportedException whilst trying to change the text of a textbox from a background thread. I used to get a detailed exception telling me not to update the textbox from a background thread.
The only difference these days is that I am developing for Windows Mobile. Is there something I am doing wrong My App seems to hang when debugging instead of giving me a proper exception.
I hope I have explained this well enough.
Thanks

Compact Framework 2.0 & Windows Mobile 5.0 NotSupportedException
n.somu
Thanks Ilya,
I seem to remember getting an exception stated that I couldn't call a UI textbox from a background thread. Maybe that was in a desktop application
Thumper III
If you mean the type of exception, you can either catch specific exception or check its type with “is” operator in C# (not sure what's the equivalent in VB):
try
{
// Do something
}
catch (NotSupportedException e)
{
// Oops, that's not supported
}
catch (Exception e)
{
// Some other exception
if (e is ArgumentOutOfRangeException)
{
// Argument must be out of range
}
}
As to what exception actually means, you can check exception message. Too bad in NETCF exception messages are not available for all exception, so sometimes it's tough to figure out what's wrong. Not in this case, though as exception message is available.
Randay
Sody
Yes, you have explained it well and this is very common mistake.
Accessing UI elements from none-UI threads is not supported, you should use Control.Invoke(). That is enforced in NETCF V2 which throws NotSupportedException you're getting. In NETCF V1 there’s no exception thrown so you can sort of do that. In most cases your application will hang on the first attempt.
Same is applicable to desktop, but it only hangs from time to time. You should check if InvokeRequired (V2 only) is true and use Control.Invoke() in that case.
zhangrusi
Yes, I believe it is on desktop in V2. V1 does not have this check.
Rob S
Ah yes,
That makes perfect sense now. In my remove programs on the Pocket PC 2003, there is the SR cab, but it is not displaying on the Windows Mobile Pocket PC (even though it gets deployed each time).
Is it easy enough to install that manually for the developement process
ZeeGee
Martin R
First of all, exception type is NotSupportedException. You're referring to exception message which are only available on NETCF if special SR CAB with these messages is installed. Please make sure it is installed, you can check in "Remove programs"
Or you can be using NETCF V1 which does not throw exception in that situation at all.
asuleman
Hey Ilya,
Why is it that Pocket PC 2003 does display a "Must use Control.Invoke" type of exception, but Windows Mobile 2005 doesn't
Rod A.
Hi..
I have face the problem when I convert my program from wm 2003 to wm 5.0
In wm 5.0, it come out an error say " Control.Invoke must be used to interact with controls created on a separate thread". But when I deploy in wm 2003, this kind of problem wont come out.
Can u all try to explain to me..
Thanks a lot..