Exception

M

Meels Lilbok

Hi

On my ASUS P535, Win.Mob.6 i get "An error message cannot be displayed
because an optional resource assembly containing it cannot be found"
VS2008, CF2.0.

System_SR_ENU.CAB and System_SR_ENU_wm.cab are installed on device, still no
luck.

Strange is i get erro when i try to set label text inside
thePort_DataReceived(serialport datareceived event)


Any ideas?


Best regards;
Meelis
 
S

Simon Hart [MVP]

Are you sure you have installed the correct framework version
System_SR_ENU_wm as CF 1.0 and CF 2.0 both have the same names.

Also some 3rd party localization packages have been reported to be buggy and
incomplete and might prevent your localized resources from working properly.
Check to see what you have installed recently.

With regards to the error you receive when setting a label.Text property
inside the DataReceived event handler which is called by the SerialPort
class. This error is due to the fact that this event is called from a worker
thread from within the SerialPort class.

Here is a small clip from MSDN regarding the SerialPort class:

"The DataReceived event is raised on a secondary thread when data is
received from the SerialPort object. Because this event is raised on a
secondary thread, and not the main thread, attempting to modify some elements
in the main thread, such as UI elements, could raise a threading exception.
If it is necessary to modify elements in the main Form or Control, post
change requests back using Invoke, which will do the work on the proper
thread."

See here for more info:
http://msdn2.microsoft.com/en-us/library/system.io.ports.serialport.datareceived.aspx

A simple solution is to use the Control.Invoke method inside your event
handler which calls a delegate that points to a method in order to execute
the UI code on the UI (main) thread. See here for information on how to do
this: http://msdn2.microsoft.com/en-us/library/zyzhdc6b.aspx
 
W

William LaMartin

I had the exact same problem the other day on a Win Mobile 6 device. And
after researching it, I installed the System_SR_ENU_wm.cab on the device to
no affect.

What worked for me was one of the following, and I can't recall which:

1. to actually create a cab file for the application and then to install it
on the device.

2. From Visual Studio, debug the application on the device.

Whichever, it was, I recall seeing it install several additional files on
the device.
 

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