views:

2320

answers:

9

I have been searching high and low for a way to get my silverlight application talking to the COM port on my local computer. Has anybody out there been able to get Silverlight to successfully connect to the COM port of you local computer? If so can you point me to the documentation.

+4  A: 

This can not be done with Silverlight.

Why not just use a standard .NET desktop app? If you need to easily deploy over the web, just use Click-Once for deployment.

Chris Pietschmann
because I wanted a zero install scenario.
Nick Berardi
You should really look into Click-Once. It pretty much does "zero install". You can launch the app right from the website in One Click.
Chris Pietschmann
Well, not really one click. They should call it Click-Once-Or-Maybe-Two-Or-Three-Times.
Jason Jackson
+1  A: 

By local computer do you mean the computer the silverlight client app is running on? Silverlight runs in a security sandbox, and it is doubtful you can connect to hardware resources like so.

Ely
+4  A: 

There's no access to computer resources, but you can communicate with sockets. So it's possible to have your users install an application which listens on a port and communicates with a COM port.

Why are you trying to communicate with a COM port? If you're looking for webcam support, take a look at Jonas's hack which uses Flash to get webcam input: http://jonas.follesoe.no/WebcamInSilverlight2MacGyverStyle.aspx

Jon Galloway
+1  A: 

Jon,

I am actually trying to read my GPS from Silverlight. I have an interesting concept that I wanted to try out, but I was trying to go for a zero install footprint.

Nick Berardi
A: 

Would WPF be a better solution?

Ely
+2  A: 

I think the guys have summed it up nicely - Silverlight is in a tight sandbox and you will not get access to the COM port or other local resources.

So let's start to think about alternatives:

  • Use ClickOnce and a full .NET application - Gives you easy deployment and udpates, and you will have the full power of the .NET framework.
  • Use a XBAP (Browser Deployed WPF) that requests some extra permissions. Would live inside the browser, but only run on Windows machines with .NET 3.0 / 3.5 installed
  • Write an ActiveX control that talks to the GPS device and expose an API. Then use JavaScript to consume this API and interact with the JavaScript code from Silverlight. This would give you a in-browser GPS application, but your users would have to install an additional GPS ActiveX component.

Cheers, Jonas

Jonas Follesø
+2  A: 

You can do this by opening a socket connection from your Silverlight control to a local socket which intern have the COM port access

Jobi Joy
And you could build the socket server as a normal winforms or console application which would allow you to run it on both windows and mac
TimothyP
+4  A: 

Silverlight 4 enables you to communciate with COM (ActiveX). I have written a blog article about how to communicate with a COM library that supports communicating with the serial port.

http://tech-michael.blogspot.com/2009/12/silverlight-talking-to-arduino.html

Michael
A: 

What if you want your application to run on Windows and Mac? Silverlight is a nice solution since it runs on both. If you have to write a WPF app or an ActiveX control, etc., this will bind you to Windows only again.

Martin Barina