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.
Related
I am thinking of making a website using a WPF browser application, but would like to know the minimum requirement a client/internet user must have to access this website made by using WPF.
Please state even the very basic requirements, like does he need to run Windows or will even Mac and Linux do, with any browser to view the application?
Three main requirements:
User has to run the application under Windows;
The browser should be either Interned Explorer or Firefox;
The .Net Framework should be installed on user's machine.
One requirement is to have the .NET framework installed (same version as you used to build your application), so that means it will only run under Windows.
Also I think only Internet Explorer and Firefox support XBAP applications.
Also I assume that you know there is a lot of restrictions for you, the developer, on what is allowed or not compared to a full trust program. For example, the file system and registry among other things are restricted in a WPF browser application.
We are planning to build a new integration component that can provide us access to user's machine installed apps from our web site.
The first word that came to me was ActiveX, but our expertise with the technology was not the best in the past.
Thinkink a lit bit more, the work Silverlight also came to my head, but the full trust thing was one of the few things I remembered reading about the technology..
The question is: is there a way that Silverlight (2, 3, 4, whatever) can run as a full trusted application from within the browser?
Links are appreciated.
Filipe
Unfortunately, no. Full trust is a feature of Silverlight 4, currently in beta, and is restricted to out-of-browser applications.
Additionally, full trust SL4 applications do not have unrestricted access to the system (particularly file system), though this may change before before release (if I have anything to do with it).
Edit: If you are considering ActiveX (which is Windows/IE only), you might want to have a look at WPF, since it can run full trust from the browser (if it's in a trusted zone).
No, like Richard said, this is not at all possible inside the browser, even in SL4. There is a sandbox, and you live in it. You can talk to web services, other Silverlight applications or the browser.
By talking to the browser, I mean you can talk to the DOM and the Javascript engine. We needed to launch a Windows application and communicate to it via Silverlight. We accomplished this by putting a small ActiveX control in the web page. It is responsible for launching the WinForms application and handling inter-process communication to it.
This method has many drawbacks: It can only work in IE, and it only works in Windows. You might also run into permissions issues. The ActiveX component needs to be installed along with the desktop application, or as an additional download. The deployment story there is pretty awful, if you ask me.
In our case, the analysts were willing to deal with the restrictions for the re-usability of an existing application, and we consider it to be an optional feature.
Does it have to be a web application? sounds like you want a desktop app. It can be easiliy distributed with one Click deployment. Will work on windows only but since you were considering ActiveX sounds like that's what you need.
Well - if you're hosting the silverlight control from an ASP.NET application - Believe you have access to
Request.ServerVariables["AUTH_USER"];
...and you can pass that on to your control as a parameter.
D
I've made a WPF Browser Application that hosts old WinForms controls (I haven't migrated fully to WPF yet). Using WindowsFormsHost means my Browser App requires Full Trust to run. This is not a problem for me since this app is only meant to be run on the intranet at my company. However, after I deploy the xbap to a network share, it refuses to run, saying "Trust not granted".
What are the methods I can use to grant Full Trust to XBAP applications stored on my companies intranet?
So far, I've found 2 ways to do this. Through a really complicated method of installing certificates on the target machine.
Or through a simpler method, which is only suitable for intranets here:
Deploy a custom CLR Security policy
that modifies the default
permissionset for the given zone
So I did just that, and it works. Here's the detailed steps how I got it to work:
Open Control Panel > Administrative Tools > .NET Framework 2.0 Configuration
Expand Runtime Security Policy > Machine > Code Groups > All_Code
Right Click All_Code and click New…
Create a new code group, I named mine MyProject_FullTrust_Zone
Choose the URL condition type and specify the path on the network where the apps will be deployed.
Choose Use Existing permission set, and set it to Full Trust.
Now the only problem with this method, is that I have to deploy this change to hundreds of machines. So maybe there's still a simpler way to do this?
It will be possible in .Net 4.0 planning to be released in the first half of 2010. It is now in a beta phase, but it comes with a go live license which allows you to 'go live' even with a beta version of the .Net framework.
Although I haven't tried this, is the path to the XBAP added as a trusted site?
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
I'm a bit confused about hosting Silverlight apps.
On one hand I see that I can host the silverlight app on a linux server just defining the mime type, on the other I see some hosting sites saying they are silverlight compatible.
And I also want to play around with the "out of browser" funcionality of silverlight 3. What do I need to do this?
Thanks in advance
All Silverlight needs in order to be hosted on a server is the XAP file and the mime type set. Thats it. If you want your app to work "out of browser", there is nothing specific that your server needs to support either.
If you want that Silverlight app to talk to your WCF service or be hosted in an ASP page, you need those services hosted in IIS... but Silverlight, itself is just a single binary file for its distribution, which can be hosted on any site with the mime type.
Marketing buzz words beyond that.
See here for a nice overview of the new features in Silverlight 3. In particular you may want to look at the Out of Browser and Offline functions.
You don't need any particular tools to use Silverlight 3 out of browser, all you need to do is to call the Application.Current.Detach() method to detach the application.
Hosting of Silverlight applications can be done in any HTML page using the object-tag. So hosting it on a Linux server should work just fine. See here for an overview (msdn).
"silverlight compatible" I would assume just means that they have the MIME entry in place, and it's mainly marketing.
The best way to host microsoft product is by using hosting that runs with Windows OS, then you can deploy it under IIS and set the MIME. You should able to find the recommended hosting provider with windows OS by googling