Does Silverlight 3 have access to local file system, Open Excel, and print reports? - wpf

I was wondering if Silverlight 3 can be used to create line of business applications where I can use file import/export facilities, read an xls file and open Excel, use a report tool like Crsytal Reports or Reporting Services or.. is WPF needed?
I am new to Silverlight and WPF and want to decide if I can skip learning WPF. I know Silverlight is a subset of WPF but I just want to concentrate in one of the two.

Although Silverlight is sand-boxed and it isn't possible to open and save files to the local file system direcly, it is possible to get a stream to a local file.
There are the OpenFileDialog and SaveFileDialog classes. These classes make it possible to let the user select a file or location. They return only a stream to that file and do not give any information about the filesystem. This way it's possible to import and export to excel for example.
This example should be enough to get you going.
update:
in the meantime I did a small SilverBullet(tm) on the subject on my blog at http://www.timmykokke.com/

Silverlight 3 has quite limited file system access. Even though you can save a local file you cannot open it using the associated application directly from Silverlight. If you want the user to export and open an Excel file from a button click in Silverlight you will have to consider alternatives:
You can open a new browser window pointed at a URL on your webserver that generates an Excel file. If the server sets the correct content type and the client is properly configured the user will be prompted to open the file in Excel. This effectively moves your export code to the server.
You can embed an ActiveX control on the same page as the Silverlight control and using the browser object you can operate this ActiveX control from Silverlight. Given enough rights by the user the ActiveX control can do anything to the local computer including automating Excel.

No, but apparently SL4 does!
Local file access - Silverlight 4

No, but unlike Jimmy my guess is that it won't happen in a future.
If you need local system there are other technologies to use (e.g. local windows service which can communicate with silverlight app).
The reason why silverlight won't have local access in the nearest future is that Microsoft learned it's lesson with ActiveX.

No, as far as I know Silverlight 3 is still as sand-boxed as ever. This is becoming a bottleneck for developers though, so I'm sure it will be addressed in upcoming versions of Silverlight.

From what I know, SL3 doenst support to use COM application such as Word, Excel, etc.. but SL4 does. If your application is just gonna be used internally, WPF will be the best candidate for your project, but if you want it to be used from the external clients as well, then I reckon you can use SL4, then use OUT OF BROWSER, then it'll work really similar with WPF. Plus with SL4, you're able to interact with Excel, Word, etc... to do lots of things.
Cheers,
Brandon

Related

Create a .dll from a Silverlight Web Application

I programmed a Virtual Keyboard (On Screen Keyboard) as a Silverlight Web Application, now I want to use this Keyboard in an other Silverlight Application (call the Keyboard when clicking a Textbox). I thought I could create a .dll and use this in my other Application.
So is it possible to create a .dll File from a Silverlight Web Application?
Thank you for reading,
Knut Hansen
You simply need to convert it into a Silverlight Class Library. There are some things to look out for, but it isn't too hard.
It is one of the options when you create a new project in Visual Studio.
See Microsoft's documentation for more info:
http://msdn.microsoft.com/en-us/library/cc838164(v=vs.95).aspx#silverlight_class_library_project
also you can think of a web service, in this way your application can be used by anyone else, of course you can specify users of your app. I think web services are more recent and using them is more future-oriented, give it a go!

Understanding Silverlight

I've just started learning Silverlight and I learned it is a client side program. Suppose I write a Silverlight app and add it to a webpage which is hosted on my desktop. If in the code-behind, I iterate through all the files in C:\StackOverflow and display the results on the page, when a user visits the page from another computer, will the program look for C:\StackOverflow on his computer, and not mine?
That's correct, the Silverlight content is executed on the client computer.
However you wouldn't be able to access C:\StackOverflow because the plugin is sandboxed for obvious security reasons.
You don't have access to the local file system directly within a Silverlight application since the application could compromise the system; it is abstracted away.
An OOB Silverlight application has increased trust but still does not provide complete access to the file system as would a WinForms or WPF application.
usually the Silverlight application will be hosted on some server..
you can send to the client data from the server
and you can access your own folders through the server (if it's on your computer)
Be aware to don't confuse ASPX code-behind and XAML code-behind.
The first one executes on the server (and in your case, if correct privileges are granted, will show files on your computer).
The second one executes on the client, AFTER the download of the applet. Unfortunatly it can't list such folder, because of security resctrictions.

What are the big major drawbacks porting a wpf LOB to silverlight 4

I am thinking about porting my alpha WPF MVVM application to silverlight.
I do not use 3D its a LOB ;-)
What I promise myself from the conversion is to get more customers in the end (Mac/nix user do not pay well ;P).
1.) At the moment I am using sqlite as database. Is it possible, that I can access the sqlite file on the harddisk of my user to read/save data? (on User dir its possible but access an USB stick ?)
2.) Is there anything concerning MVVM silverlight can not handle?
3.) Does SEO work well with Silverlight 4?
1.) At the moment I am using sqlite as database. Is it possible, that I can access the sqlite file on the harddisk of my user to read/save data? (on User dir its possible but access an USB stick ?)
If you want to use a local database then you'll either need to install your Silverlight application on the local machine as a full trust application or use a database that installs into Isolated Storage like SiaqoDb (as suggested by #Shawn Mclean). You won't be able to access a USB stick.
When run in a browser across the net it has limited access to the local hard drive for security reasons. If you're doing this you might as well stick with WPF.
2.) Is there anything concerning MVVM silverlight can not handle?
You can use Prism to develop MVVM applications for Silverlight as well as WPF.
3.) Does SEO work well with Silverlight 4?
I don't know a great deal about this, but Silverlight can be viewed as Microsoft's version of Flash so it will probably have the same SEO issues as Flash. The code is compiled and delivered to the client in binary form, so unless you split your application across multiple HTML/ASP.NET pages there won't be anything for Google to index. Apparently Flash does support SEO, but I haven't looked into SEO and Silverlight.
1.) At the moment I am using sqlite as database. Is it possible, that I can access the sqlite file on the harddisk of my user to read/save data? (on User dir its possible but access an USB stick ?)
The basic principal of Silverlight is centralised data over services. You can have local data, but that is not as useful generally compared to a central storage. You then have no worries about full trust as it will run in any Silverlight browser.
You can use SQLLite on your server, however the best free database option we have found is SQL Service Express 2008 R2.
You can access USB, but it requires both OOB, Full Trust and a custom COM automation object installed on the client (so Windows only). Basically forget local USB storage and support downloads instead, if local copies are needed.
2.) Is there anything concerning MVVM silverlight can not handle?
Bindings in Silverlight 4 are now very similar to those in WFP. Accessing parent elements from templates is a little more difficult, but most simple bindings are the same.
3.) Does SEO work well with Silverlight 4?
First ensure that you provide a sitemap for the searchengines. That should map to all content pages.
Provide a parallel ASP.Net website to publish your content for the search engines to read. This is now quite easy with RIA services as an ASP.Net website can consume a RIA service just like any other WCF service.
Make good use of headers, meta tags, titles, human-readable urls to include relevant keywords.

Burn a CD from Silverlight

I have a Silverlight application with a large DataGrid. I have added the ability to export the contents of that DataGrid to Excel, PDF, and several other formats. In my export dialog, I have a checkbox that says "Burn to CD". The reason I'm trying to do this is my user base really wants to be able to export files directly to a CD.
My question is, is this even possible with Silverlight? I think I can do this through COM interop which was unveiled with Silverlight 4. But I know that COM interop is limited to Windows, because of this cross-platform support would be nixed. I guess my questions are:
Can I burn to a CD with Silverlight?
Is COM Interop "the way" to accomplish this?
Is there a way to burn to a CD from Silverlight on the Mac?
Thank you!
COM Interop is only possible within Out-Of-Browser mode and with elevated rights. Also COM is Microsoft only so you wont be able to use that with Macintosh.
Maybe you can generate an ISO or ZIP file on the server side, or even on client-side if you'd want and deliver that to the user, that way the user can decide to store it on an USB stick or burn to a CD theirself.

Silverlight SQL Deployment

I'm about to write an application in either Adobe Air or Silverlight, to run standalone, offline, on the desktop. It's a simple enough application that allows the user to enter text data and will then print formatted documents based on that information. The obvious place to store all this relational data is in a database. I believe Air comes with SQLite out of the box, so no problems there, but from what I can tell Silverlight doesn't. How does Silverlight handle installing an out of browser application that needs to access a local database? Does the user have to install SQL/SQLite first and then Silverlight, or is there some way that Silverlight can deploy that side of things itself?
Thanks
I don't know much about Air, But Silverlight has IsolatedStorage for saving data on client-end and it has its own constrains. But if you want to have an application that can access local database why don't you try WPF(XBAP)?
This link can be helpful regarding SQLLite and Silverlight using IsolatedStorage.
http://forums.silverlight.net/forums/p/118411/267135.aspx
Regards.
I'm fairly certain silverlight isn't intended for... whatever it is you're trying to do.

Resources