views:

40

answers:

0

Hi all, I'm working on a concept that will allow Silverlight to communicate with POS peripherals by using the POS for .Net library. I need to be able to able to call into the library to catch bar-code scans and print receipts etc. This all works fine if the application is a winforms app but in my proof of concept console app it the event handler is being called when I perform a scan but the scanner object seems to be lost. I can see via the threads window in the debugger that the event is getting created on a new worker thread. My understanding is that this is the issue as the context is getting lost. The error when trying to access the scanner object is:

DisconnectedContext was detected Message: Context 0x20b800 is disconnected. No proxy will be used to service the request on the COM component. This may cause corruption or data loss. To avoid this problem, please ensure that all contexts/apartments stay alive until the application is completely done with the RuntimeCallableWrappers that represent COM components that live inside them.

I believe the solution is to either create all the COM parts on the same thread or else to somehow correctly marshal back to the main thread.

I'm pretty stuck at this point and would really appreciate any help you can proveide.

Cheers, Darren.