Posts Tagged ‘Silverlight 3’

DeepZoom demo download - Uploading images and the Auto DeepZoom xap generation

Monday, September 14th, 2009

Click here to download the solution

Below is the logical architecture

dz

Click here to download the solution

DeepZoom.sln - visual studio 2008 c# solution includes all the projects. Make sure you have the silverlight 3 tools for visual studi0 2008 installed(www.silverlight.net)

Solution contains the following projects

WebApplication Tier Project

DZWebSite Project - Sample Silverlight 3 App to upload image
DZWebSite.Web Project - Sample html/aspx page to host DZWebSite silverlight control

WCF Service

DataTransferService project - WCF Service which implements IStreamService ServiceContract and UploadFileMessage DataContract

Service Libraries(Windows Service or ConsoleApp)

Utility project - implements a syncqueue and a thread helper
DeepZoomService.Common project - implements DynamicService and FileSystemWatcherBase
DynamicService.cs - implements dynamic windows service using reflection and the configuration file
FileSystemWatcherBase.cs - abstract class for file system
DZService Project - library implements all the services, deepzoom image generation

Windows Service
DeepZoomWindowsService Project - .NET Windows Service functionality same as console app but part of windows SCM

DeepZoom Package

DeepZoom Project - silverlight control without xaml file, responsible for creating MultiScaleImage control and setting the source for deepzoom xml file. You can also inject code at runtime to change the zoom icon or other parameters

TestHarness

DeepZoomConsoleApp Project - Running services in a Console App(easier for debugging), no need to deploy. Instantiates the services as configured in app.config file, by default there are 2 services configured (ImageService and MaintenanceService)

DTServiceConsoleHost Project - test app for testing WCF service

READ ME

Please do the followings if you just want to run it after downloading

1. create a web site (http://localhost/streamsvs) with physical path set to “\DeepZoomService\DataTransferService\ ” to host WCF Upload Service

2. Create a website with physical path “DZWebSite.Web” to browse to Silverlight client app to upload a file

3. Download folder.zip for folder structure used by WCF/Windows/Console service to write and process uploaded images. By default, “C:\DeepZoomService\Customers\TestCustomer” is used by WCF service for uploaded files.  “C:\DeepZoomService\Host\TestCustomer” is used by Windows/Console service to generate deepzoom package and the path for testpage

4. Create a site http://localhost/dzpreview/TestCustomer with physical path “C:\DeepZoomService\Host\TestCustomer”, this site is used to host generated deepzoom package in a test page. The link for test page is generated on silverlight client page once the file is uploaded.

5. Execute “\DeepZoomService\DeepZoomConsoleApp\bin\Debug\DeepZoomConsoleApp.exe” to execute the service to monitor the file system and to process the uploaded images to deepzoom package

The best way to start looking into it is by debugging DeepZoomConsoleApp project

Share/Save/Bookmark

Silverlight 3 OutOfBrowser(OOB) behind the scenes Explained, how to host a silverlight xap package OOB style without installing it - read/modify silverlight OOB metadata

Friday, July 17th, 2009

You can find a sample on www.silverlight.net or google(bing) it. The purpose of this post is not to show you how to create a Out Of Browser(OOB) application using visual studio / Silverlight but what happens behind the scene and how you can re-use a silverlight xap package to deploy it on any machine by xcopy or a media drive and run it as a desktop application out of browser style.
First of All, creating a Silverlight Out of Browser Application is one line of code and the change in deployment manifest. Please refer to http://timheuer.com/blog/archive/2009/03/18/silverlight-3-offline-update-framework.aspx to understand silverlight offline/update behavior

In order to support Out of Browser in Silverlight, you just need to call Application.Current.Install() on user action as shown below.

private void Button_Click(object sender, RoutedEventArgs e)
{
Application.Current.Install();
}

When you install the application, it downloads the content(xap package) and generate the html file to host silverlight along with some metadata. Everything is generated at isolated storage, which will be the followings in Windows XP and 2003bi

<systemdrive>:\Documents and Settings\<username>\Local Settings\Application Data\Microsoft\Silverlight\OutOfBrowser\<appid>

AppId is generated at runtime which includes some random number along with domain name so for example, if you are browsing it on a localhost, AppId could be something like “2748978495.localhost”.

How does OutOfBrowser Silverlight 3 App Work?

1. Silverlight 3 runtime installs “sllauncher.exe” to launch a silverlight xap package, on my machine it is installed at <system drive>:\Program Files\Microsoft Silverlight\sllauncher.exe

2. When you install Silverlight App as  OOB, it downloads the xap package at isolated storage

3. Silverlight runtime creates a “metadata” and generate “index.html” file to host the silverlight control at isolated storage

4. When you click on shortcut or start-> to launch Silverlight app, it has a command line target to launch “sllauncher.exe <appid>”, appid is nothing but the isolated storage folder name

5. sllauncher is a win32 app which loads silverlight plugin(npctrl.dll) along with IEFrame.dll to host silverlight

6. Isolated storage also includes “index.html” which hosts the silverlight xap package, “sllauncher.exe” loads IEFrame to host html/silverlight control using browser host service

Below is the snapshot of isolated storage when you install silverlight application as out of browser

isolated storage snapshot

What does metadata contain?

Silverlight metadata for out of browser application as shown below can be directly edited in a hex editor(unicoded string , not a binary file) or a notepad
metadata snapshot

You can open it using any text editor, no need of using hex editor.

I have quickly put together a wpf app with bunch of controls slapped in to read/modify silverlight oob metadata, click to download along with source form here to view/modify metadata

Below is the snapshot of Silveright Out of browser application modified metadata
sl metadata viewer snapshot

You can pretty much modify everything in metadata.

Can I modify metadata or run out of browser silverlight xap package without downloading it?

Absolutey, Out of Browser is not really out of browser because you do need a host to host silverlight xap package so Silverlight Team did a clever implementation to load html file using SLLAUNCHER.exe and of course sllauncher uses the same infrastructure as real browser does by loading silverlight plugin(npctrl.dll-com dll)  to bootstrap silverlight core clr.

Steps to create your own out of browser silverlight app to host any xap package without downloading/installing it from silverlight app on internet

1.  click to download SLMetaData along with source to view/modify metadata , it also includes a zip file with metadata,xap and html which you can unzip to execute sllauncher.exe

2. launch slmetadata.exe and click on File->Open to open “metadata”

3. Modify any of the field you want and click on to save the metadata

4. Create “index.html” file and specify the xap package path as shown below

<html xmlns=”http://www.w3.org/1999/xhtml” >
<head>
<style type=’text/css’>
html, body { height: 100%; overflow: auto; }
body { padding: 0; margin: 0; }
#silverlightControlHost { height: 100%; }
</style>
</head>
<body scroll=”no” onload=”document.getElementById(’_sl’).focus()”>
<div id=”silverlightControlHost”>
<object id=’_sl’ data=”data:application/x-silverlight,” type=”application/x-silverlight” width=”100%” height=”100%”>
<param name=”source” value=”D:/SilverlightOOB/application.xap”/>
<param name=”background” value=”White”/>
<param name=”enableGPUAcceleration” value=”False”/>
<a href=”http://go.microsoft.com/fwlink/?LinkID=124807″ style=”text-decoration: none;”>
<img src=”http://go.microsoft.com/fwlink/?LinkId=108181″ alt=”Get Microsoft Silverlight” style=”border-style: none”/>
</a>
</object>
<iframe style=’visibility:hidden;height:0;width:0;border:0px’></iframe>
</div>
</body>
</html>

5. Make sure that the path to the “index.html” file is same as specified under the LaunchPath in metadata

6. Make sure that the name of the metadata file is “metadata” and is copied at the same location as your html file

7. Execute the following command “sllauncher.exe <folder path to html file>”, make sure sllaucnher.exe is in your path :-)

8. you can also download the complete zip package to try it out by executing the above command

for example -”sllauncher.exe D:\SilverlightOOB”

That’s all, Silverlight OOB is possible with the help of loader which gets installed along with silverlight 3 runtime which does use IEFrame so not really out of browser :-) but out of browser indeed

Below is the snapshot of html, folder path and command prompt
html snapshot

FolderPath Snapshot

folder snapshot

Command Prompt Snapshot

command snapshot

Share/Save/Bookmark

Akismet - Spam Blocked
March 2010
M T W T F S S
« Feb    
1234567
891011121314
15161718192021
22232425262728
293031  
Categories