Click here to Skip to main content
13,054,329 members (122,210 online)
Rate this:
Please Sign up or sign in to vote.
See more:
Hi everybody at Code Project., I've created a small application which is designed and written in Silverlight 5 (vb). I chose to use the out of browser settings (OOB) for the application because I did not want to use a whole page just for a small calculator application. My question is can I still attach and run the OOB application from a website online without a user being able to download it? What is the procedure for deployment to a server? I'm assuming that once deployed to the server a link from the web page would enable running of the application? I'm a complete novice in this area so any advice would be much appreciated.
Kind regards
Posted 2-Nov-12 10:11am

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

If you look at the attached web project that hosts your app for testing (in Visual Studio), you will see that there is some javascript and html in that page to drive your SL app. You have to have that as a page on your deployment server as that code declares the SL runtime as a object in the page DOM and instructs the client browser to download and run your app in the local SL runtime.

Your final xap is always downloaded to the client. To put it "on the web" you have to upload the xap to a web server. Then the hosting page has to have the embedded SL runtime object which points to the xap you want to run when that page is loaded. A user would go to to get to that page which, in turn, would load the SL runtime on their client machine. The SL runtime would then make the call to download and run the xap specified as a parameter to the object.

The difference with an OOB SL app is that the runtime does not require the browser host and the user must explicitly authorize the installation (via a right-click of the app in the browser). There are other security restrictions and such but for your app I doubt they will come into play.

So... to directly answer you... your app is automatically a browser app AND an OOB app (assuming you have made it OOB) and can be run either way by default. You can change this behavior by detecting the RunningOutOfBrowser property and presenting a different interface when in-browser.

willrob68 2-Nov-12 17:13pm
Hi, Thanks for your help, so is it the case that when I do a build of the SL OOB app that the javascript and the html that you have pointed out to me are included in the release folder ready for deployment or are these files something that I have to add separately? Is there a deployment option to a server address within visual studio? I'm assuming that If I leave the Install menu check box unchecked that a user would not be able to download and install to a client machine?
Kind regards
willrob68 2-Nov-12 18:25pm
Hi again, I can see all of the above mentioned files in the web folder in the visual studio projects. Is this just a case of deploying the contents of this folder to a server? and if so how? Is there a deploy option within visual studio where you can set the path/address/password etc to the client server?
Jason Gleim 2-Nov-12 19:59pm
You can publish directly to a server and you set that up in Visual Studio. I believe it is part of the build menu but please don't quote me on that. However, there are only two pieces you actually need to deploy the solution on a web server. You need a HTML page that includes the Silverlight runtime object and you need only the .xap file. You will find the .xap in the output of your Silverlight project. There will be a bunch of files and folders in that location but you only need the .xap file, that is your entire Silverlight application wrapped up into one.

To get it on the web, you need to copy it to a location on a web server... it might something like An FTP client or some other means of getting it uploaded will work here. You should be able to enter the URL into a browser and get prompted to download the xap. If you do, then the xap is ready to go.

As for the html page, you could create that in notepad or use the one in the web project as a basis. It can be a very simple file and instructions on what is should contain can be found here: Once you have that file, upload it to a web server in the same manner as you did the xap. You should then be able to enter something like to open that page (obviously with whatever name and URL you gave it.) If you follow the directions on that MSDN page and adjust your xap path accordingly, it should open the page, load the SL runtime, and start your app.

Understand... this will run your app in the browser... which is how all SL apps MUST start out. ALL Silverlight apps are ALWAYS runable in the browser. If you want to run it OOB, you must right-click on the app in the browser, and select 'Install' from the pop-up menu. When you do that, your machine will download the xap and enable it to be run OOB. The advantage is that it doesn't have to check the server to run the app if it can't reach it. Of course, if you have any web services that depend on a live server, that is a different problem. ;-)

You can detect whether your app is being run in-browser or OOB. If you want it to be an OOB ony app, you have to detect that it is running in-browser and put up a different page that instructs the user to right-click to install it. In this case, it is still running in the browser... you just don't provide any functionality in that mode.

willrob68 3-Nov-12 8:49am
Hi Jason, I had a look in the build menu, the publish option is there but it has been made un-selectable i.e. greyed out. In the projects of visual studio for my SL project there are two folders: 1, my app.web and 2, my app, In the web folder this contains the following : Testpage.aspx, TestPage.html, Silverlight.Js, web.config and then a sub folder called bin containing the .xap file.
In the second folder (my app) this contains just about everything that is in the solution explorer in visual studio. Is it the case that the important files that I need have already been segregated from this folder and have been put into the web folder? When I run the app and I right click on it I only get the option to remove the application or go to a silverlight configuration menu? (Strange because I haven't installed it) I suppose this could be due to the fact that I left the show install menu box unchecked in the OOB browser settings. What I was hoping to do is run the SL app from the website and not let the user download it to their machines but I want to keep the OOB dimensions for the app. You were explaining the html web page, is the one that is created in visual studio no good?
Jason Gleim 3-Nov-12 9:22am
You should be able to find your compiled xap as /my app/bin/release/my app.xap. If you found it under my app.web, it is probably the version copied over when you run your app in Visual Studio.

You probably can't publish it directly from VS because it isn't signed. I wouldn't worry too much about that.

The Testpage.aspx, TestPage.html, and Silverlight.js files make up the local test deployment. You could use those as the basis of a web deployment but since they are designed for IIS it may be more trouble than it is worth. It might be easier to follow the directions in that MSDN article I referenced.

As for 'downloading' your Silverlight app, I think we might have gotten confused over the technicalities. To run a Silverlight application, at a minimum, you must have a hosting page (html, asp, etc) and the xap file on a web server. Your app gets opened when someone visits the page that contains your application. This is the same as Flash content or any other embedded add-in. They are all included in the page via an embedded object. Again, the MSDN page goes over all of that.

When someone opens a page in this manner, their browser downloads the xap file, just like it downloads pictures, media, or other page elements. That isn't easily accessible but it can be found because it all goes into the temporary internet files location. But... you can't directly run the xap from there. Even if someone found the downloaded xap, if they double-clicked it, it would not run. It MUST be hosted in a web page.

If you marked your project as an OOB application, an extra menu item shows up when the application is right-clicked in the browser window. That is the "Install Out of Browser" option. Users which select that will "install" the Silverlight app into their machine. It is still possible for that user to run the Silverlight app from the web page but it is also possible for them to run it without the browser. Don't confuse marking a Silverlight app as OOB with turning it into a desktop application... that is not the case.

There are some great articles out there on deploying SL apps to a web server and on enabling OOB. If I were you, I would concentrate on getting the app deployed to an Internet web server first. Make sure all of that is working and you understand the process. THEN move on to making the app OOB. Even if you want the application ONLY available as OOB, you still have to do the first part and get it deployed to a server.

Let me know if that helps!
willrob68 3-Nov-12 12:28pm
jason you have been a great help. Just Out of interest would it have made things smoother if I'd got the app signed?
Kind regards
Jason Gleim 3-Nov-12 13:19pm
No worries... glad I could help. I had to figure a lot of this out when I first started with SL back in the day.

Signing probably wouldn't have given you many advantages. It would allow for the publishing but you would have to have a compatible web server with WebDav or something like that.

If your app required elevated trust settings.. for example if you needed to access the hardware on the machine it was running on or access files outside of Iso Storage... then you would have to sign it to run as a full trusted app. But really, all of that just complicates things for little benefit. I wouldn't worry about signing it unless you have to because of some other need.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web01 | 2.8.170713.1 | Last Updated 2 Nov 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100