views:

1453

answers:

3

To summarize, as we all know,

a) Silverlight is expected to be hosted by a browser, and runs in an isolated sandbox so that there won’t be any security issues

  1. Silverlight don’t have direct access to the file system, other than the isolated storage area
  2. There is no direct way to open common dialog boxes like File Save in Silverlight (Though Opendialog box is supported).

b) Silverlight can’t access local resources like a printer

What are the ways to go beyond the sandbox, so that I can host a Silverlight application locally, to read files and save them back if required, to hand over data to a printer, and so on..

Update:

Is full WPF is not an option for me? No. I'm also interested in a cross platform solution - for instance, you could host Silverlight in Mono Web browser control, so that you can run it virtually anywhere.

The idea is to re-use the same application that I'm building for web in my desktop as well, by providing separation of concerns at some areas - like persistence, resource access etc. Scenarios:

1- Some kind of gadget container, with access to local resources. 2 - A desktop Silver light based media application

Update:

I just did a POC to enable me to access printer and save files locally, of course through a shell where I'm hosting my Silverlight application. If you wan't you can have a look at the post here in my blog

+6  A: 
amazedsaint
Embedded web server? For a client application? This might be a bit overengineered.
Gurdas Nijor
Yes, when you don't have a better choice
amazedsaint
+3  A: 

Is a full WPF application not an option for your situation?

As you probably know Silverlight uses a subset of WPF so you may be able to change your application relatively easy.

A wpf app would be easier than having a web server etc bundled within your application.

You wont in the foreseeable future be able to have access to resources such as printer and files (apart from isolated storage) through Silverlight as you know.

You could have a seperate part of your app to upload files to the webserver then read these in your silverlight app from a service.

Depending on your printing requirements (e.g. if you just want to send everything to an office printer) you could send the informaton you wanted printed to a service that will then print it for you. However I am guessing you want each client machine to be able to print in which case this wont work for you.

alexmac
The idea is NOT to use WPF - so that I'll end up with two code bases. Also, see my update, like how I'm accessing the printer now from my silverlight app. :)
amazedsaint
+1  A: 

I am attempting to also reuse a codebase for both desktop and silverlight. There are two options that I know of in addition to the ones mentioned

If you directly reference (instead of a project reference) a silverlight dll from a normal project, it should work. This would let you reference a silverlight dll for both projects.

Have two project files (one wpf, one silverlight) that point to the same set of files. You might have to have to use a few compiler flags here and there, but this should let you use the same files for both.

Jacob Adams
See my update above to learn why this is not a good option for me. I'm also interested in running this in Mono.
amazedsaint