Silverlight 4 gives access to the user's microphone and camera, and adds printing capabilities, but as far as hardware goes, that's it. Fortunately Silverlight 4 also provides access in Elevated Trust Out-Of-Browser applications to COM. If you need to access other local hardware, providing a COM component is the solution. This example provides a COM object written in C# and addressed by a Silverlight application. BackgroundMy company provides vertical market software and normally supplies peripherals as well. Typical devices include things like cash drawers and card swipe readers. These are usually serial devices. Customers have also been asking for web based solutions to avoid the usual distribution and update issues of locally installed software. Silverlight now provides a great user experience but hardware access is essential. I have no experience writing COM objects (and not too much using them), so this was a voyage of discovery for me. I had to piece together a number of different articles and examples to get something to work. I hope you can benefit by having a complete example. Example ProblemFor my example, I'm simulating a three drawer cash drawer stack. The application needs three basic functions:Open a drawer by drawer number.
Check the status of a particular drawer.
Receive an event if a drawer is opened or closed.
The example solution contains a Windows class library which simulates the device class and exposes the necessary methods and events to COM. Also in the solution is a very simple Silverlight test application. The COM object targets the 2.0 Framework. The Silverlight application that consumes it is a Silverlight 4 project.Read more: Codeproject
Check the status of a particular drawer.
Receive an event if a drawer is opened or closed.
The example solution contains a Windows class library which simulates the device class and exposes the necessary methods and events to COM. Also in the solution is a very simple Silverlight test application. The COM object targets the 2.0 Framework. The Silverlight application that consumes it is a Silverlight 4 project.Read more: Codeproject