Friday, 26 October 2007

Working with Sql user instances

Just a quick note, as I've not been very active on this blog for the last few weeks. I still have a lot of content in the pipeline so expect a new tips'n'tricks article next week. I've been preparing some stuff to publish at TechEd as well, so if you are going to be around let me know I'll show you some fun stuff.

Also I'll be releasing a tool to help work with sql express user instances and attached database files that I've been working on. Hopefully you'll find this useful.

Stay tuned...

Monday, 15 October 2007

Microsoft and the Magic sweet spot

As I was coding away on the train today, for a few minutes my mind blanked while watching the landscapes Virgin offer to us regular travelers. The did an amazing job at decorating the length of the track, to the point where you'd nearly get fooled into thinking there are actually villages, cows and other things between London and Manchester. As it happens sometimes, I started thinking about my early days as a fresh and learning developer, many many years ago.

Against the normal academic training some IT people receive, I evolved as a developer from the top down. I didn't do University and got no degree in IT. I actually got as far as studying law. I learnt everything by starting to write HTML web sites back in 95, then started JavaScript in 96 and VB in 97, and discovered JScript.net and C# when I got through a friend an early preview of what was to become .net (NGWS anyone?). And I'll admit that while I understand how x86 works and how pointers work, I am absolutely unable to write a single like of C++ or any other esoteric close to the metal languages (I hope esoteric here is not taken as a challenge of C++ usefulness, as I'm sure the gurus amongst you will have understood). And it's only after all these years of coding that I start understanding calling conventions, Win32, etc.

It all got me thinking about how you understand a language and a platform. Until you reach the thorough knowledge that only years of experience will bring you, you often ignore the why question, preferring the answer to the how: you care about how you achieve a result, with the acceptance that you do not understand why it needs to be done in a specific way.

For example, in JavaScript, you'd add a method to an object type by adding it to its prototype property. You know that instance methods and type methods are two different beasts intuitively, because var $cube = new Cube(); $cube.getValue = function () { return 2; } will not work for another Cube you'd create later on. This empirical knowledge is surface magic for however long you'll take to dig deeper, learn and discover what a prototype is and how it relates to objects. At this stage, if things go wrong you'll probably have to learn more things. And it's an open ended confusing thing because both $cube.getValue and $cube.prototype.getValue can exist.

Another example comes from the WPF world.. Whenever you create a custom library of Controls for WPF, you learn about themes and how styles and templates get applied to your controls. You know that the themes being selected for a control are the end of the line customizations you provide, and you know you have to declare an attribute at the assembly level, and we're still very much in the domain of empirical knowledge. But you also know that the fallback when you don't provide themes is a file in the themes folder called general.xaml. You know the how but the why has no answer. It is a decision the framework designers took, and you have no way of changing it or influencing it in any way. This by design rule is crystal magic. The behavior cannot be changed, and once you learn how to do it, the why question is irrelevant. And if it doesn't work, there's no additional knowledge cost, because you don't need to learn anything else.

My point in all that is that these two magical elements have conflicting developer audiences. More Junior developers (and some senior developers I've worked with in the past), let's call them Mortimer, are happy with crystal magic, because it massively reduces the surface of the API you need to learn. More senior developers that have a will to understand (anyone that uses reflector as his main documentation tool would fall in this category), let's call them Einstein, tolerate surface magic because they can crack the surface, dig deeper and know all the intimate details of how the surface is achieved. They don't necessarily like crystal magic because it just works and they have no control over it, but as it's a closed ending, there's nothing that can be done about it, so they move on.

Everything would be for the best if surface magic worked for Mortimer. APIs like WCF provide a very simple surface magic, with only ServiceContract, OperationContract and DataContract concepts to learn. With the tooling support for WCF services in visual studio, the surface is small enough for most developers to start being productive very quickly. The reality strikes as soon as something unexpected happens: passing too big of an object graph, or worse, a cyclic reference within the DataContracts. Suddenly, Mortimer faces understanding notions such as bindings, behaviors, configuration files, and many other concepts that multiplies exponentially the API surface they need to understand before they can fix a problem. You just designed an API that targets Mortimer when everything works, but that requires Einstein to fix if anything goes wrong.  That said, tooling support is appropriate for being productive, which should ensure WCF adoption, so we're pretty close to the sweet point.

WPF on the other hand has a bit of both. Xaml is easy enough for Mortimer: it's understandable and can be fixed by Mortimer, because most of the bindings between DependencyObject and Xaml follows a crystal magic design. The property store will map Xaml and DependencyProperties based on the name, and nothing you want or can do will change this. You also very much pay as you go when you learn Xaml, because you can start with simple object graphs, and discover attached properties at a later time. You can use them without understanding them, and often you'll be able to fix issues by learning a bit about the Binding syntax. On the other hand, it's a very large platform and requires much more time than Mortimer would spend learning a new technology. Areas like Bindings are complex when they don't work, outputting errors to the debug window is confusing when you don't know where to look, the coexistence of logical and visual trees is difficult to grasp for winforms developers, etc.  Tooling support should help, but from what I see in beta 2, I don't believe the sweet spot will be hit with this version of Visual Studio.

And finally PowerShell is a deliciously efficient crystal magic solution. Things work as expected, pipes and formats work by magic, using a defined behavior that will not change. The framework is static enough that people are confident that the knowledge they learn using the script engine will be valid whichever Commandlet they call. The built-in variables work automatically. $_ will always have the same meaning, $$ too.

What Microsoft doesn't have anymore is a completely crystal magic solution for development. ASP was very much crystal magic, ColdFusion was too, back in the CFML days. Early days VB had few extensibility points which let developers grasp the platform more easily. PHP still has a bit of that feel, just like many other frameworks that limit choice and extensibility to increase the pace at which their developers become experts. When most of your developers know 80%+ of your API, you know you're on the right track. Anything under that and you face a problem: You're segmenting your market between Mortimer and Einstein. Your Mortimer has to get more knowledgeable to survive your technology update, your Einstein will just keep doing his expert job. The low end of the Mortimer market is gone to join the ranks of other easier and simpler technologies.

The sweet spot is not to try and provide one API for everyone, but to provide one crystal magic API for the quick and easy, and a completely different solution for Einstein and upgraded Mortimer.

Getting dynamically typed languages with the DLR is going the right direction. But now, this is a call for action to you Microsoft: Provide us with simple tools with a lot of magic to gain back the people gone to LAMP. Give us a forms design tool that maps any control on a form if the form is named after a table and a control is named after a field in that table. Give us a web tool that simply easy work with no mvc, no presenter, and a simple script language to inject a bit of server side code where it makes sense.

And remember that a crystal magic API is one that you *do not extend*. Not everyone needs a framework.

P.S.: This is just my opinion on why we're loosing so many people to php and other simpler technologies. I have a lot of designer friends that just plain refuse to touch any Microsoft technologies, because PHP is so simple. I'm probably not the target audience for any of this. Any resemblance with current or previous coworkers is purely intentional. No guarantees implied or granted. Do not use in a nuclear facility. Etc.

Technorati Tags: , ,

Wednesday, 10 October 2007

The tale of the annoying read-only ConfigurationElement

One of the piece of code I disseminate on each project I work on is a lightweight factory builder. The idea is that you declare which interfaces are implemented by which types, or constructed by which builder. It's perfect for replacing all the types you abstract when unit testing, and put the responsibility of the dependency injection on the configuration file.

Here's a small example of how one would declare an interface as having a concrete implementation.

<factories>
  <factory interface-type="CaffeineIT.Blog.IConfigProvider, CaffeineIT.Blog.Demo"
           concrete-type="CaffeineIT.Blog.SettingsConfigProvider, CaffeineIT.Blog.Demo" />
</factories>

Very straightforward. From your code you initialize the type like so.

var myConfig = FactoryActivator.CreateInstance<IConfigProvider>();

The problem when unit testing my configuration sections is that they're read-only by default. That means I need to do some black magic swapping config files around when running my tests.

Well, it's not very well documented, but with the help of reflector, you discover the secret so many have kept to themselves. To make your ConfigurationElement read-write, override the SetReadOnly method and do nothing.

protected override void SetReadOnly()
{
    //do nothing!
}

I don't know about you but I feel like I'm cheating.

Technorati Tags: ,

Sunday, 7 October 2007

WPF Tips'n'Tricks #8: Use your code-behind for binding

In the View-ViewModel-DataModel pattern that has been documented a fair bit for WPF, it is often the case that you want to have a testable class that wraps your data to expose an object model that will make binding from Xaml code easier. However, when writing prototyping or simply answering messages on the Msdn forums, as well as for the code examples on my blog, it's often the case that you want to have a sort-of ViewModel that you want to quickly hack together.

The solution is to simply leverage the code-behind of your window! Let's create a simple property on our window code-behind.

    public partial class MainWindow : Window

    {

        public MainWindow()

        {

            InitializeComponent();

        }

 

 

        public bool IsFlagSet

        {

            get { return (bool)GetValue(_isFlagSetProperty); }

            set { SetValue(_isFlagSetProperty, value); }

        }

        public static readonly DependencyProperty _isFlagSetProperty =

            DependencyProperty.Register("IsFlagSet", typeof(bool), typeof(MainWindow), new FrameworkPropertyMetadata(false));

 

    }

And now in the Xaml code you just need to bind the DataContext property to the class itself.

<Window x:Class="CaffeineIT.Blog.XamlCollections.MainWindow"

  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

  DataContext="{Binding RelativeSource={RelativeSource Self}}">

    <TextBlock>The flag value is:

        <TextBlock Text="{Binding Path=IsFlagSet}"/>

    </TextBlock>

</Window>

Voila! You can now bind straight to the properties defined on your Window class! But as the complexity of your project increases, you'll want to unit test the ViewModel, and for this you'll have to separate the code in a separate class. The way I choose to do it is to embed the object directly inside the Xaml code. With this approach, you'll have the a ViewModel class. Here I implement it by inheriting from DependencyObject to keep the DP we defined earlier, as it provides support for validate and coerce callbacks, but this is absolutely not necessary. You're more than welcome to implement your property through accessors and INotifyPropertyChanged.

    public class NewWindowViewModel : DependencyObject

    {

        public bool IsFlagSet

        {

            get { return (bool)GetValue(_isFlagSetProperty); }

            set { SetValue(_isFlagSetProperty, value); }

        }

        public static readonly DependencyProperty _isFlagSetProperty =

            DependencyProperty.Register("IsFlagSet", typeof(bool), typeof(NewWindowViewModel), new PropertyMetadata(false));

    }

And now I can declare this object in my Xaml.

<Window x:Class="CaffeineIT.Blog.ViewModel.NewWindow"

  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

  xmlns:vm="clr-namespace:CaffeineIT.Blog.ViewModel" DataContext="{DynamicResource ViewModel}">

    <Window.Resources>

        <vm:NewWindowViewModel x:Key="ViewModel" />

    </Window.Resources>

    <TextBlock>The flag value is:

        <TextBlock Text="{Binding Path=IsFlagSet}"/>

    </TextBlock>

</Window>

I find the code very tidy. Through this mechanism, you can also bind properties from your view to the ViewModel. Imagine: View updates ViewModel updates View... You can abstract all the logic of your view in your ViewModel in an oh-so-clean way it makes me salivate every time. You can then leverage commands to encapsulate actions that modifies the ViewModel which update the View. No more tier leakage!

Technorati Tags: , , ,

Wednesday, 3 October 2007

.net source code to be released

From ScottGu, the source code for the .net framework libraries is going to be released, and on a source code server. This is thrilling news. Makes me regret spending all this time within WPF internals through reflector! Does that include comments in the source files?

Sunday, 30 September 2007

Software that sucks #1: Why you should do your testing on the train

This is a new rant series where I moan and exhibit my frustration with using some software that has been designed or tested by monkeys. I'll try as much as I can to be constructive and propose reasonable solutions, but sometimes there's just nothing to do to save software with poor design or engineering.

One more week-end, once more another 03:50 hours train trip. I do like these travel times as I feel I knock down work for this blog the most efficiently when I'm on the train.

One thing I don't have is proper connectivity. I have a Vodafone Mobile Connect ExpressCard for my beloved MacBook Pro, which does ensure a nice and easy 3g+ connection to the Internet wherever I am (how I wish apple would include a UMTS/HSDPA chip in their laptop so I could do without the express card). But you see, while France has a vast network of high speed trains on which they ensure mobile phones work (and Paris even has phone connectivity in the tube!), Shakespeare's land is not as gifted. Reception on the London - Manchester line is dreadful, with a few areas with 3G or 3G+ (if the train is stopped), some areas with GPRS, and a few areas where the signal drops too much for anything to go through. As a result, my card disconnects and reconnects every couple of seconds. And that's where I'll do my strangest assertion to date: If you develop any kind of connected application that may be used on a laptop, plan for your testing to happen on the train.

The regular loss of connection for a short while should be and is supported by the TCP stack to a certain extent. But your application *should not* rely on the connection being there. Separating the use of the data from the reception / emission of the data should be priority number one of application developers, and timeout / crash / retry management should be baked in. Outlook does this with it's offline Exchange mode, that separates the caching and receiving of emails between local and remote store, and the displaying of the local store.

However, Internet Explorer doesn't seem to work the same way. It has trouble with displaying web sites if the TCP connection gets suddenly suspended for a while: after doing a small network trace with ethereal, the data gets received again, but for some reason wininet decides to hang in there for a while and do nothing, even if you start a new tab. Closing and reopening the browser solves the issue.

Where it makes me scream is when it's not software, but drivers that encounter these issues. Like the ExpressCard driver. Has any of the engineers working on this driver ever tried it in low reception areas? Expect crashes, hangs, your mouse blocking for a few seconds. Absolutely dreadful. And all this on Windows Vista of course.

Technorati Tags: , , , ,

Saturday, 29 September 2007

MediaElement and MediaPlayer, and the ocx control fairy tale

As some of you know I'm always monitoring the msdn forums. I usually only step in the conversation when no one else had or when it's a complex subject I know something about. That leaves me with very few contributions :)

That said, I often read from Microsoft people and from external people that anything that plays in Windows Media Player will play in the WPF video elements, that it uses the windows media player ocx under the hood, or that the content runs in WMP in another process.

So I thought I'll clear up a bit how the rendering of video is done, from the few sources I've found and from some experimenting.

First I created a small WPF application containing a small video, and I ran Process Explorer on it to see what was actually loaded.

image

There's a few interesting things happening there which I think are interesting to naute. First let's review the components that are running. wmp.dll is the core library for Windows Media Player; quartz.dll is DirectShow related; evr.dll is the Enhanced Video Renderer; wdmaud.drv and dsound.dll are audio related; d3d9.dll is what is used for WPF rendering and part of Direct3D; and a bunch of filters like msmpeg2vdec.dll and some .ax splitters files that don't show on that capture. Finally, we have MilCore.dll.

We know that MilCore.dll is the unmanaged part of WPF, and is responsible for composition and rendering. It's built on top of Direct3d. We can deduct that MilCore.dll is the one implementing the audio / video playing, because it exports functions such as MilMediaSetIsScrubbingEnabled, MilMediaOpen, etc.

What we do also know is that for WPF to render video inside the composited graph, it takes whatever default DirectShow graph created automagically for a specific file, and replaces the normal rendering surface by the EVR. As explained on msdn, the EVR is a new renderer shipping as part of Vista that can be used for both DirectShow and MediaFoundation pipelines for rendering and compositing video streams. It's been said before that the renderer is also shipped as part of .net 3.0. Don't be surprised if some media center applications not built on WPF still have a requirement of .net 3.0 exactly for that reason: Leverage the EVR to replace the ageing VMR9. You can find more information on these on Msdn. Finally, the EVR supports a model where you can replace Presenters, aka the surface on which the video gets rendered. And we know from an msdn post that WPF ships its own Presenter.

In passing, that's where you may encounter scrubbing issues on XP. The presenter is the only component knowing intimately about your hardware. It's as such the one that will know about the vsync on your monitor. In XP, the custom presenter synchronizes with the composition engine, but that engine is only on one window. The windows themselves are still in GDI/USER32 land. Without knowing enough of how the composition engine works, I still assume tearing still happens exactly for this reason, even though the WPF content is a retained mode scene. On windows Vista, the same composition engine is used to do a composition for a WPF application or for the whole desktop. As I understand it, it is actually only one rendering tree, where GDI apps are just a node in the tree with a graphic, whereas a WPF app has a whole visual tree, which in turn is what lets the magnifier on Vista to properly zoom on WPF content.

Well, there you are. The difference between plain old Windows Media Player and WPF is large enough (different renderer) that there's no guarantees that a video playing in WMP will play without issues on WPF. All this still begs the question as to why is the WPF team using wmp.dll rather than go straight to DirectShow? I would place my bet on not duplicating engineering work, as Windows Media Player now supports initializing either the MediaFoundation or the DirectShow pipeline based on the file, and leveraging that support would save code duplication. Or it could be something completely different.

But what we can say is that the Windows Media Player process *is not executed*. We can also say that while it's true that there's a linking to wmp.dll and the use of COM interfaces, it is not possible to say if an actual ActiveX control or OCX is used or if some code is not leveraged for DirectShow/MediaFoundation graph construction.

Friday, 28 September 2007

Office Outlook Connector for Windows Live Hotmail's new version doesn't work!

Well, I was forced to do an update this morning and of course I can no longer access my Windows Live Hotmail account from outlook!

Windows Live team, with auto update comes great responsibility, and you just failed me.

Programming WPF 2nd edition

Just received this morning as part of my review of all the major WPF books, and what a shock. The first edition was quite short, the second is 800 pages!

Half way through the ChrisA, and quarter of the way in Nathan's, i'll do the Petzold last so I expect to be reading Ian & Sells book sometime in the next two weeks.

Technorati Tags: , ,

Tuesday, 25 September 2007

WPF Tips'n'Tricks #7: Smooth(er) scrolling

A common request with ListViews and other scrollable components is to have a smoother scrolling. By default, when a scrollable control contains items that control their own scrolling, it jumps from one item to the other, by the whole item height. It's not smooth because it's not animated, a step back in usability that I still cannot explain (lack of time maybe?)

The culprits are mainly the Panels like StackPanel and ScrollContentPresenter that don't implement smooth scrolling animations. While changing their behavior to support smooth animation is a way to solve the issue, and it may well be that I start implementing it for a future Tips'n'Tricks, but for now it's out of scope for this entry.

So how to prevent this jumpy behavior? Don't let the content decide how it's going to scroll! It's very easily accomplished, by adding the ScrollViewer.CanContentScroll attached property and setting it to false. Here's a small example:

<Window 
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Smooth Scrolling Demo" Height="300" Width="300">
<Grid>
<ListBox ScrollViewer.CanContentScroll="False">

<ListBox.Items>
<TextBlock Height="40">Text1</TextBlock>
<TextBlock Height="40">Text2</TextBlock>
<TextBlock Height="40">Text3</TextBlock>
<TextBlock Height="40">Text4</TextBlock>
<TextBlock Height="40">Text5</TextBlock>
<TextBlock Height="40">Text6</TextBlock>
<TextBlock Height="40">Text7</TextBlock>
<TextBlock Height="40">Text8</TextBlock>
<TextBlock Height="40">Text9</TextBlock>
<TextBlock Height="40">Text10</TextBlock>
</ListBox.Items>
</ListBox>
</Grid>
</Window>

[Update]
Ronan is absolutely correct in pointing out in my comments:

There's a drawback when using this trick: when ScrollViewer.CanContentScroll is set you loose default scrolling behaviour of the ListBox which uses a VirtualStackPanel. On big collections you will notice a great performance degradation.

This is a complete oversight in this tips'n'tricks. Virtualization means that only visible items within a list will be created and added to the visual tree. Not an issue for a few items, but when you reach the hundreds or thousands, it becomes a necessity. When you set the CanContentScroll property, the virtualizing stack panel stops virtualizing and renders everything. Be aware of that!

And as is also pointed in that comment, making a smooth scrolling *virtualizing* panel is even harder.

Technorati Tags: , ,

Saturday, 22 September 2007

Multiple .config files

A good tip from Scott Hanselman. on how to manage multiple configuration files. I end up rewriting these pre-build batches every time I'm on a new project, now I'll have a central space to copy the code from!

Tuesday, 18 September 2007

Excel and Sql, or the joys of data massages

A problem we encounter too often is extracting data the business stores in an excel spreadsheet. The way some people deal with it is way too often to copy and paste all this in T-SQL code and have long integration scripts.

This causes two major problems. The first one is that you rely on your database to integrate data in your application from other systems. The vast majority of products have validation logic and application integrity checks into your application code, and rarely in the database schema. Not only that, but you suddenly expose as a public and exposed system what should remain an implementation detail of your service. In the end, you just made changes to your database structures an order of magnitude more difficult, which now decreases the maintainability of your code.

And don't even get me started on testability of T-SQL integration scripts, even with the new VS for database professionals unit testing. It just doesn't add up.

That said, the not to do is often the was done and conflicts with the needs to be done by tomorrow. Often enough a project cannot (or doesn't want to) afford a proper integration between their systems, as these projects come in expensive. Often, good enough is what the business wants, and the business controls the budget.

And in these cases, you often have to deal with data from Excel and Access. Few people actually know that you can query these files from within your T-SQL code, by using the OPENROWSET command, which gives you whichever table you want to select, through the table name or through a query.

In this instance I've just spent a good hour trying to understand why my excel spreadsheet opened through the OpenRecordset would return me a column full of null values when the spreadsheet itself had the correct values.

As usual, the answer is hidden in the knowledge base, KB194124. Excel tries to guess the datatype of a column, and gives you null if it fails. Rule of thumb, never trust anything that tries being smart.

Solution is to switch excel to import mode, by changing the connection string you use to add IMEX=1:

SELECT * INTO #xl FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0',
'Excel 8.0;Database=file.xls;IMEX=1;', ['Festival List$'])

And I'm back in business!

[UPDATE: Added some commentary. Also changed the text around a bit, sometimes I realize my English gets fuzzy when I don't proof read before posting. Sorry chaps.]

Technorati Tags: , ,

Friday, 14 September 2007

Executing Sql scripts from powershell

Realizing I still have 6 Tips'n'Tricks articles nearly ready to go to follow up on the series, but none of them are finished, I thought I'd give you another powershell trick.

One of the main issue on windows when interop has to be achieved between powershell and cmd is the issue of CreateProcess trying sometimes to be too smart about quotes. That's why powershell supports being called with a base64 encoded parameter as command line parameters, and why attempts to use variables when calling sqlcmd.exe fail miserably.

So I wrote a quick hack script that concatenates data in a nice batch file and then executes the batch file. I've used it on several projects by now. Anyone wanting to make it more fancy don't hesitate.

function Execute-SqlFile($file, [string]$Server, [string]$dbName, [hashtable]$variables, [switch]$WindowsAuthentication=$true, [string]$Username, [string]$Password) {
        $batch = (join-Path (cat env:TEMP) "exec_sql.bat")
        write-Host Connecting to $Server
    
        $output = (join-Path $env:TEMP "output_sql.txt")
        if (test-Path $batch) {
           Remove-Item $batch -force
        }
        $data = ""
        if (test-Path $batch) { Remove-Item $batch }
        $data += "sqlcmd -S $Server"
        
        if ($WindowsAuthentication) {
            $data += ' -E'
        } else {
            $data += " -U $Username -P $Password"
        }
        if ($dbname) {
            $data += " -d $dbName"
        }
        
        if ($variables -and $variables.Count -gt 0) {
            $data += ' -v '
            $isFirst = $true
            foreach($key in $variables.keys) {
            
                if (! $isFirst) { $data += ' ' } else { $isFirst=$false }
        
                $val = $variables[$key]
                $data += "$key="
                $data += "`"$val`""
                
            }
        }
        $data += " -i `"$file`""
        
        
        $data += " -o `"$output`""
        
        $data | Add-Content $batch -force
        
        cmd /c (Resolve-Path $batch)
        
        gc $output

    }

Which lets you call it like so:

PS C:\WINDOWS\> Execute-SqlScript "local.sql" "dbserver" @{key="value"; key2="value2"}

Enjoy!

Technorati Tags: , , ,

Wednesday, 12 September 2007

Mix:UK 07: Sneak Peeks

Bamboo flute playing with the audience.

Demo of 3D application showing someone's head captured with an MRI, followed by a foot, with bones and flesh being coloured. A sneak peek within us.

Sea Dragon: How to deal with high resolution images, that will be included in Silverlight 1.1 [EDIT: This is the technology used by PhotoSynth]. This lets you stream high resolution images. Demonstration of a commercial for a car that lets you zoom in very deeply until a corner of the image reveals text and a dashboard.

Technology to deliver ads. Project Gatineau is part of adCenter. Some of the demo should be available in beta by the end of the month. Through a report, you can see graphs based on the age of users, which is collected through LiveID.

There's also visualization technology which lets you see where people navigate. There's also a marketing campaign which shows a timeline.

There's a treemap visualization of traffic. This provide tools to let a web site owner to know where people navigate. You can subscribe for the beta on the advertisement web site.

Simon Peyton Jones from Microsoft Research does a presentation about the multicore challenge. Because of the increase in the number of cores, processors are not getting faster anymore. So you need to do task parallelism.

To do parallelism, you need to use concurrent programming objects that have been the same for 30 years, with no progress.

What's wrong with locks? First you can forget the lock, and you have a race condition. Or you take them in wrong order and you have a deadlock. Condition variables get threads to block if someone forgets to notify. And error recovery is very difficult. But theres worse. Locks are absurdly difficult. Sequential code is doable by undergraduate, locks and condition variables done right gets you a publishable paper at an international conference.

Atomic memory transaction: If we could wrap code inside an atomic clause, there would be all-or-nothing semantics: That's the Atomic from ACID. They execute in Isolation. And there's no lock.

How could it work? With Optimistic concurrency. Execute the code without taking locks. Each read and write in the code is logged to a thread-local log. Writes go to the log only, not to memory. At the end, the transaction tries to commit to memory. Commit may fail, then transaction is re-run.

How to do blocking? You could add retry. Retry says "abandon the current transaction and re-execute it from scratch". The system could keep a reference to all the reads you did and only re-exeute the transaction when one changes.

Locks don't compose well. If within an atomic code block there's a request for retry, the whole transaction retries. They also compose well with choice, which lets execute either a segment of the code or another. If code1 retries, execute code2. If code2 retries, the whole transaction will be retried.

There's a run-time cost, but a compiler technology and hardware support can reduce it a lot. It's better to have a correct program than a fast program. Finally transactions can even be faster as there's no locks and it's more fine-grained.

Graphs shows that it's actually faster than fine-grained locking, while being more scalable.

Atomic blocks will be a step forward. IT's like using a high level language instead of assembly code. It's not a silver bullet, you can still have concurrency errors. You can still introduce bugs, but they're much more interesting bugs.

There's a implementation available today in STM Haskell: http://haskell.org/ghc Theres a tutorial on STM in the book beautiful code And there's other papers at http://research.microsoft.com/users/simonpj/

Demo of a video tool that lets you drag and drop videos on a timeline in low-resolution, done in Silverlight with Sharepoint integration.

Expression Web 2 supports PHP!

LiveStation: Silverlight application streaming video from a peer2peer network. There is no browser!

There's a game coming out soon: Halo3! With actual footage from the game.

[EDIT: And finally, we've all received a copy of Vista Ultimate and a copy of Expression Studio! Which is fabulous considering I moaned about wanting a license to Expression Studio at the dinner the night before!]

Technorati Tags:

Tuesday, 11 September 2007

Mix:UK 07: Cloud versus Client

Panel debate. [EDIT: You'll have to excuse me but too many names to write down.]

Chairman: First question, for Danny that comes from Google that worked on Gears. Danny: One of the first question is, what if you loose the connection? You have offline storage. Google Gears have that, Isolated Storage in Silverlight is another one. When you look at rich applications, versus rich apps on the client, you always need a backup plan for offline. For a game, where content is downloaded, you can run offline. For a big database system like email, you can emulate or proxy until you go back online.

ScottGu: The concept of offline storage is an interesting one in the web. It's usefulness is questionable, because of interop. When you build apps, you have a responsibility to make it work. It can be daunting if a new browser come, etc, if you want to guarantee availability.

Danny: I think it's a question of how in the long term we want the browser to involve.

Speaker 5: Offline issue is less a problem because silverlight streaming is highly redundant. Writing is on the wall for traditional hosting. If it's highly available, and can be delivered in the cloud, it lower my cost, why would I need traditional hosting?

Michael Ford: I commute 2h a day. I have a 3G card. I use Google reader, it's integrated with Google gear, download the feeds and as the connection goes in and out the connection is seamless. In my company we're working on a desktop application that is computationally intensive. What silverlight lets us offload the calculation engine on the client. It's also better security as it runs in a sandbox makes it interesting.

Rob Blackwell: What bothers me is the user experience piece. The evolution has been to provide richer and richer interfaces. If you look at the horse power of chips and networks, everything is available. We're nearly at the point where it's an exponential curve. We're going to see tremendous increase on the client and people will want to increase the quality on the UI, like HD DVD. When I go on holiday i easily fill 10GB.

Chairman: Angus arrived.

Danny: There's two points. The client cloud offline storage there's two model. First there's a copy of the client, or there's a cache on the client. You still need to think of it being on the cloud. As PC and devices use expands, people have access to the Internet on many different devices. Their personal life experience is available on all this, this is very empowering.

Public: We do that on email, flicker, etc.

Danny: How long after gmail did someone hacked it for a GDrive.

Public: How do you keep people confident with storing their data in the cloud?

Speaker 5: There's a lot of issues with that and it all comes down to terms of services. Service agreements are usually missing, you can contribute with terms of uses that don't guarantee you'll get your data back. Microsoft does a lot of work on that.

Michael: I have a gmail account, I archive everything, but I always have half an eye that someone is keeping it.

Rob: What about the enterprise scenario, they're not always technologically savvy.

Danny: With Oracle, if you stop paying, they take your data away. With the advent of larger data centers, on top of that there's SO. Microsoft has audits about privacy but thats just because of antitrust. There should be audits for everyone.

Public: Large amount of need for space is copyright material. If we move t the web, who controls that, if they move copyrighted dvds, music, etc.

Danny: On the thousand people uploading the same CD, there are tricks and techniques to recognize patterns. Don't know how many data centers do that. If it's cruelly high security type storage that most vendors don't do, theyre not the same bits because partitioned. There should be personal backup copies as per the law so shouldn't be an issue.

Phil Winstanley: Copyright is a big issue. Cloud based projects go and create mash ups. People can create more and share more, rather than distribute songs like they used to do.

Public: What about mesh computing and going on other machines.

Speaker 5: Silverlight streaming is about storing and delivering. I get the ability to build applications on top of other platforms that i couldn't have done on my own. It provides a model for distributing computing.

Danny: The mesh computing causes an issue if there's a single point of failure thats covered but if your connection go down you're screwed.

Public: What about WiMax? I have 250Gig hard drive on an ipod, connect it to the network. If you have enough bandwidth at home you don't need the local storage. But if the connection goes down, you dont have it.

Danny: And the more bandwidth available for you, the backbone needs to be able to scale. Not sure if the economics work.

Public: You're held hostage by people providing the bandwidth. They want a share of it for high bandwidth providers.

Dany: AT&T blames google for that situation. If google makes money out of ads on youtube then they should pay a share of the money.

Public: We're on a technological rift. We were client-server. Then the web. Now we put the execution engine back on the client, stil going to the servers. What about an execution platform on the crowd.

Michael: I prefer client applications to web applications. I don't think the browser is a fantastic platform for a rich client. With silverlight its getting better but I need my calendar always available.

Public: Why use google reader instead of outlook?

Michael: Outlook? Ouch. No there's probably clients I could use.

Speaker 5: It's different this time becase there's a huge network. Now were looking at the web as a platform. We have more functionality and services.

Danny: There's a balance that's hard to drive in either direction. There's more processor time available than a user will use at any time, whereas how many technical problems fit into a mesh network. It doesn't work on little probems very well.

Phil: Browsers are not designed to do what we make them to do. We can't wait for the browser to give the functionality anymore. Thats a fact of development.

ScottGu: The browser has a lot of challenges. From the distributed perspective, the browser changed some things for the better. Each app used to be a silo talking to one database. Now you can link to a blog, to a profile, my mom using an app doesn't know using the application goes to the web. Silverlight, flash or server processing. The web taught us asynchronous programming in a distributed way. The expectation is for the app not to freeze. Considering how wide is the network we work on. You gonna see people use AJAX, client, Silverlight, Flash, and combine them. The end result will be richer than it's been on either the server or the client.

Danny: Cross domain security for the browser. The browser is secured for cross domain. At the time it was a reasonable compromise, vertical and monolithyc, except viruses. But vendors have evolved faster the browser and we now hit the issue.

Speaker 4: If you use the conchango application on the USB stick, its going online for some services, but it works offline. If you have a client running many operating systems then you want the browser. If you control the platform, you can do client. With Silverlight you have an easy way to leverage your assets.

[EDIT: Missed a question there]

Public: What can the panel say about issues with the cloud?

Danny: Issues with the cloud, there were vulnerabilities, then they could get a huge amount of data in a very short time. That's why datacenters have proactive security, and kill parts of the network as needed.

Angus: There's a bot that's more powerful than the fastest supercomputer in the world. That's waht happens. Security: first version of facebook. Viral invites of people, the installation of the application exponentially.

Speaker 1: What happens with privacy, there's been a couple of password. Did the password come back or is it a new password. If it comes back, it's been stored unprotected. What if someone hacks in the system, suddenly they have all the passwords.

Danny: On the same vein, to do our Live Services available to developers, we have to do these exercises, the user has to see the data transferred. That puts the load on the user and makes the process more difficult.

Angus: It's at the detriment at the user experience. Nothing can be rosy when you share a bed around.

Public: TKMaxx had issue, it's not only the cloud, it's the same issue.

Public: Originally, we did online bank access. They now send card readers to swap your card and PIN [EDIT: SmartCard]. But on the other hand they send faster. If i'm in the USA I can't. The very big commerce sites will start doing propriotary ways.

Public: The net will end up in anarchy and end the human race.

Danny: I'd like to comment on the behavior changes. We see that already. The young generation have a completely different view of their personal data. Things like myspace, they don't have much worry about who see their data. There's already a cultural shift.

Phil: People are more open, they write a public diary 16-24, and what they put in there is quite, hum, interesting. Personal knowledge of someone is very powerful.

Public: Cambridge people were showing themselves on pictures getting drunk and they got fired.

Rob: My father used to distrust banks, and keep the money under the mattress. There's been a change there.

ScottGu: Same issue existed 10 years ago. Now they just take this for granted. If a company wants to stay running they have to protect my information. Today there's a lot of issues with law firms, can you buy people's private data. That's going to be an interesting shift.

Angus: Some company wants to spend money to know me to tell me what I want.

Public: From a disaster recovery point of view, with the cloud everything is still available. If you need high availability you're better off on the cloud. Access is not an issue.

Danny: In your home network you have the same reliability issues. You share documents but if a machine goes offline or your wifi goes offline you can't edit your word document

Angus: I think replication across the cloud is the killer application.

Public: Is there a way to have server only code?

ScottGu: First, can we have a core framework, with core set of libraries? That's what we use in silverlight, Server Core in Windows Server Core with no GUI, with IIS. You can't run .net code yet but we'll see in the future. You'll see more factored versions. Silverlight is the first version where we pulled all these things out.

Public: There's so much data now compared to a few phone numbers before. Young persons now just drop their email address when there's too much junk. Data becomes very disposable. As we go on how do we deal with that volume of data ad use it to our advantage.

Danny: I think someone said that information available in our day to day life per person is equivalent to one you had at all 10 years ago.

Public: 8 or 9 years ago, it was LiveJournal, then myspace, facebook. But they change, trends change. Wikipedia may be available for a few years.

Public: How do we get around legal issues across boundaries, data stored in the US about users in Europe for example. How does that work with a cloud.

Danny I do know that companies specialize in offshore data.

Phil Winstanley: mp3.com has shown that it was legal in their countries. It's unresolved.

Angus: if you shift a lot of data to China, its going to be expensive, you're better off having a datacenter there.

Danny: As for corporate use, privacy and protection, security metrics will be about IP addresses and MAC addresses access. As part of SLAs and Terms of Use, there will be clauses about where the data have to be stored. It's building fences that data centers traditionally don't have.

Michael: its no more of a problem if a small company starts trading in another country. Like antifascist laws in Germany prevents you from providing Nazi content.

Danny: Can a local market censor for everyone what one country sees.

[UPDATE: Added names for speakers and corrected some spelling mistakes]

Technorati Tags: ,

So far so good...

Lot of typing but its worth it. Hopefully people will find the content useful. Note that I mostly retranscript what's being said, so when I type I its not me talking. My comments are in bracket with a big EDIT: in the front :)

I am the culprit

Two softies blog about someone blogging like crazy at the back, that would be me!

http://blogs.msdn.com/dthorpe/archive/2007/09/11/blogging-at-remix07-london.aspx

http://blogs.msdn.com/angus_logan/archive/2007/09/11/blog-envy.aspx

Mix:UK 07: Building next generation web applications using Windows Live Services

Integrate different applications together. End users will go and download the messenger client and interact with the messenger service though that tool. Our idea is to open that service to empower developers. They'll benefit from our scale, user base and services.

There's a break down in the live platform: Rich media expriences. Silverlight well push it and stream it for you. Storing and sharing, we have messenger, all your contacts is a shared infrastructure across all our services. If you have a blog and use spaces, it goes there. We also have photo sharing. Automated agents with AI on messenger. Alert infrastructure, we send million of them at 9am and they'll turn up instantly on messenger and a few minutes later by sms.

Live.com, search, maps is the Find and Locate.

And what we announced last year at mix was to say we'd have one set of use for everyone. As a developer, a company, you read these TOCs let you use everything for free, within a cap.

Dynamics Live, Office Live, XBOX Live exist too but they're not tightly integrated, so they're not handled by us and we don't look at them.

Silverlight streaming. It's on microsoft infrastructure, and it's free. You take your application, your video, the application in its whole, like the Scrum board, and uploaded on our infrastructure where we'll manage the storage, the distribution, the backup of it, you don't need to pick up the bill for streaming it. When we go from alpha to beta, you'll be able to stream a million minutes a month for free, and above that we'll figure out a way to solve that issue.

How to use it? If you 're a developer, you go to http://silverlight.live.com with your windows live ID, it'll give you an account and you get your 4GB bucket for all your code. Once you have the application and signed up, you can upload through the web interface, which is more for a one off. If you do this a lot, user generated content, thousand of files, you can use a REST (some would say HiREST), with PUT/POST/GET/DELETE. It gets distributed to our CDN and you don't have to worry about it. Someone in China will get in a local cache for fast access over there.

How do you fetch information from there? For the Halo3 Service, all the videos come from Silverlight straming. When a user browse to http://halo3.msn.com they get all the html and javascript from that server. But you can either do a javascript or an IFRAME integration. The browser will then call our Silverlight CDN and pull down everything from there. Or you can just decide to pull down the videos, and keep the flexibility to keep your application and use our servers for the video.

Three steps, Creating, Uploading and Consuming.

Demo

Opening Expression Encoder. Was released in final version last week on the web. If youre running Vista there's three default videos, import them in Encoder, decide the encode rate, but what we want is look at the output. We choose a template. There's one small window called Publish thats an add-on to Encoder that we'll see in a bit.

We encode the video, the template gets outputed in the output directory. This encoding will take a short time, 10 seconds microsoft time.

Question: Why Microsoft gives this for free? It's a big bill, but we're saying upload your content, at a later time when you go over your limit we'll exchange more bandwith with ads. We don't know yet. The long part of the tail, the free bits, are paid for by the top of the tale, the ones that pay for it.

I got all my rendering done in my otput directory, and there's a few files i want to delete, silverlight, csproj and htm files that are used to be opening in Blend, delete them as they're not needed on the sliverlight CDN. I'll go to http://dev.live.com which should be your favourite web site. It's got SDK, samples, RSS, etc. One of the tasks is creating apps with the encoder, which gives you a full tutorial for it.

You need to create a manifest file which is an xml file. Its a silverlight 1.0 application, you can also upload 1.1. You decide which js files and which functions are called. You right click it and zip the manifest and add all the other files. Make sure you zip them at the root of the zip file or the content won't get uploaded.

You can go to the silverlight web, and you can manage all your applications from there. You can from there upload the zip file you created, choose a name and upload.

We only allow you to upload 30meg chuncks. The video portion needs to be less than 22MB. If you go over 12 minutes of content, you go over the MPEG limits, break your license.

You can launch the test application page from there and will load the content from agappdom which is the silverlight CDN network. We can do up to a terabyte per second of bandwidth for video streaming.

That was the slow way, let's look at the quick way. I have a web service in a solution within visual studio 2008 and i'm going to debug it to show what is going on. There's a couple of webmethods. One is UploadFiles. You pass the file from the test page, give a title and click Invoke. The code in the demo sets the URL to the address for the account id (http://silverlight.services.live.com/accountid), pass the data as a POST which returns an OK response. And it's been uploaded programmatically automatically.

So how do we fetch this data programmatically? We call a GetVideos method. Same URL, call a GET. One thing we're lacking a way of capturing additional metadata, for example GeoCode. You can do it manually by escaping data and uploading fake names. The web service can then return this data after decoding it. From the web service data, we get the address for the IFRAME we can put on our application. You can also get the IFRAME address manually.

Question: How did you add these extra attributes? I encoded the data and Base64 encoded them and put them as filenames. It's a hack and we'll hope to fix up.

Question: What happens if you use all your minutes for bandwidth time? It won't disconnect you, we haven't locked it down yet. Someone will shoot you an email telling you you're popular and wanting to help you more popular.

Virtual Earth is used a lot in the UK. There's a lot of aspects to it. The user experience is from http://local.live.com you can get maps, or see my street on birds eye view, or New York on 3D. They have not much to do with development. What we do is manage all the data, 14 petabytes of data, for our service. A while ago we opened it up for developers to leverage. You can use the mappoint service you have a SOAP api. You can embed a map with a javascript control. If you want to do tricky stuff like overlaying things then you can use things like Map Cruncher.

Demo of Virtual Earth.

From http://dev.live.com, you have cookbooks containing examples, that show the example, source code, references from msdn and interesting links. It shows the javascript code to show based on Longitude / Latitude, which you can get easily by lookig at the URL when you're browsing the live maps.

In this demo it's all javascript so no code behind. There's a reference to the javascript map control, and we call the GetMap, Load the Map, set the zoom level except you can't look up, we don't have that yet. We have a map showing up, its all running off the live code.

We want to push the video we saw earlier onto this map, and we do that with a pushpin. How do we do that? Back to the virtual earth SDK. There's a tool to add custom shapes, you can look at the code, and see the javascript to do that. Copy and go back to the code, we add the pushpin, add an icon, change the style, add a description. Then we call the javascript code to pull the videos. What we do is add the ScriptMethod and AJAX extensions to call that web service.

In action, there's now 3 pushpins on the map. In the Virtual Earth SDK you can add HTML content to the pushpin which lets you show HTML data whenever you click on the pushpin.

You can also switch to bird eye view or hybrid view, the pushpin is still there.

SportsDo shows a bird eye view of the trajectory of a run above a map. The thing works to where people were swimming, and in bird view you can follow their trajectory!

Another is skiing in Les Arcs, in 2d View you have a pushpin of a geo coded picture. If you switch to 3d mode. The 3d is an ActiveX control, so you can choose high ef or low def experience.

Looking in 3d you can see the contour of the mountain, and you can sin the demo around and the track followed by the skiers is still there. There was no programming changes done at all.

If you have an xbox controller, you can plug it into your PC, it will control your 3d view.

Switching to hubrid mode you can see the textures on top of the geometry of the mountain.

Last one is booking a tour of Toronto. Pictures on a Windows phone, everything gets uploaded and geo-coded. In building view you can zoom in and see the pictures overlayed on the map in 3d view of the buildings. As the track followed gets animated, the icon is automatically put behind the buildings which lets you follow where he was going. I encourage you to have a play on our site. We thnk it's a great example of what can be done with 3D.

Windows Live is opening. People have their worlds in Hotmail, Messenger, etc. If you;re doing any silverlight development, deploy it on Silverlight streaming. With one click of a button from encoder you can publish immediately. On Virtual Earth, you code once in javascript.

We have another session covering everything else on Wednesday at 12:15, covering Messenger, and some pre-release things.

Question:

What is the 700kbs limit? If you load 5 files from your domain you'd get 5 times the bandwidth. What we enforce is the average. We've capped to test how good we push on the server.

How much does it cost for Virtual Earth license for a company? I don't know come see me and leave me your email. Mappoint is another technology, which is a sister of VirtualEarth you may have to choose between the two.

Is it possible to host asp.net services on silverlight streaming? No it's about silverlight content only. You'll still have a web host for a rich asp.net experience, we only provide the silverlight answer. 3 million map tiles for free, above that there's a charge, we can put you in contact with people. There are commercial terms on search, 750k queries for free even for commercial terms.

The 22MB limit, is it going to change over time? Although it's streaming, are you doing http download of the videos? First, 22MB is a temporary which will be changed over a time limit, as long as it stays under 10 minutes limit. We'll be able to offer commercial terms, but there's MPEG royalties involved. The streaming, it's only Http.

What about live video? We don't support live video, but we offer the Windows Media Services as part of Windows Server.

On the Virtual Earth API, it looks different from maps.live.com? No answer. There's nothing different from the demo.

You mentioned an IFRAME part, where do you get the IFRAME URL from? It's in the SDK and it's released so you should be able to get it through there. It's appID and accountID.

Is there a Silverlight compatible api for VirtualEarth? Right now it's not possible, someone may be working on that. An aspect of that is that silverlight 1.1 can call out on javascript, so you can reach to the javascript code from silverlight 1.1 .net code.

Is there any plan for windows live access to receive and send live messenger? From a server point of view, we bought a company which are Windows Live Agents with an SDK ported from Java to .net to program bots against the Messenger platform. We're running an alpha and search for Windows Live Agents you'll find it. There's a lot of things that will be included in the future with contact lists.

Technorati Tags: , ,

Mix:UK 07: Building Silverlight applications using .net Part 2

I wonder if I made the right decision to only blog the second part, we shall know very soon.

Questions:

Availability: The control toolkit for silverlight, will be full source soon.

Is it possible to rename assemblies to help with SharePoint? By the next refresh, instead of building the assemblies in separate files, everything will be zipped in a common package: Secure request and dynamically compressed.

Is there a date for CE support? There's a CE version of Silverlight that was shown at the Las Vegas Mix conference. The issue is the distribution aspects on phones. We're trying to sort out a few of these issues.

For those that missed Part 1 [EDIT: I'm the only one in the room it seems], there will be a link to the slides at the end of the session.

As it happens, Part 1 was about Shapes, Controls, UI, with no code. Part two we'll talk about events and write some code, how you can create your own controls, and tak about some of the non UI aspects like networking.

You need to name your controls, which then lets you address them programatically. That's what you'll use to bind events.

The Page_Loaded event is called when the app has been downloaded, which means everything referenced inside the XAML file, including images and videos, the event won't be fired until they've all been downloaded.

What you would want to do is to load all your assets as a background task instead of waiting for everything has been loaded.

Everything youve downloaded goes through the browser cache. You don't have to download assemblies or videos twice, the browser cache handles that.

Question: Can you download byte level access to what gets downloaded? Yes we'll see that later.

You can go and bind event on any UIElement, like MouseMove, MouseEnter, tc. Al shapes and controls derive from UIElement.

You can wire your event inside your XAML file, passing it the method name that will get executed, which is similar to the way it's done in asp.net. Instead of having OnMouseEnter uses MouseEnter and doesn't have the OnXx syntax.

You can also use the Handles keyword from code in VB, or in CSharp in the Page_Loaded event handler.

Question: Can you link to external handlers? Absolutely, not declaratively, but procedurally.

Demonstration: It's a blank page, and wherever you click, it shows a text saying "Clicked". It shows code getting the point where the mouse clicked, create an element, and set the Canvas.Top and Canvas.Left attached property to the newly created element.

Another demo changes the color of a sphere whenever clicked on. By having an Ellipse in the XAML, and in code behind, the Brush, Stroke and Fill properties are being modified programmatically.

It would be painful to add shapes every time you add a button, so let's look at example 3. Three buttons. They're wired to handlers.

Dependency properties will be supported in 1.1, but not sure if property triggers will be supported.

We want people to use Events for designers to stylize the buttons without having developers writting all the wiring code.

To build your own controls, you can do that. You derive from the Control base class. You have full encapsulation, use any shape, controls, brushes, transforms, etc, and expose your properties methods and events you want. They get hooked up to XAML.

As a control developer you can take advantage of the InitializeFromXaml method that lets you get a XAML tree from a string.

To be XAMLable, you have to have a parameter-less constructor, have public properties and public events.

Demo of creating a custom control

You can crate a Silverlight class library. Once it's created, you can add a Silverlight User Control. The XAML from the resource is serialized as a resource, and the partial class loads it from the resource and uses InitializeFromXaml to load it.

There are still a lot of feature missing: TextBox and Input controls are coming on. Layout managers are coming in the final release too. Databinding and DataTemplates, and styling support. All these features will show up in 1.1.

For business apps they are essentials, so it would be a bit hard to develop Silverlight business applications, so you may want to wait.

Is there a licensing model for third party licensing model: There will be a DRM system within Silverlight so you can implement your own.

Is there a way to share common controls so they don't get downloaded all the time? There will be a mechanism for trusted web sites for clients to download only once. There is a versionning policy so if there's a specific version, you bind to that, and we bind versionned, so theres no conflcit there.

One of the core things we try to do is to integrate with existing document to use .net or javascript and HTML in the same application. If you build a .net application, you can import System.Windows.Browser which lets you reach outside and get the HTML DOM, works on all browsers. There's an HtmlPage object so you can navigate to other pages or get all the documents. You can use the GetElementByID to return a reference an object in the page from your code. You can use an AttachEvent to attach a DOM event and give a reference to your .net method, in any language, CSharp, VB, Python, etc. The code for AttachEvent works across all browsers because it's the .net code, it is not related to the javascript way of attaching events.

Question If you want have a client side event handler, what happens? AttachEvent respect the existing attachments.

You can reach out from Silverlight in HTML. You can then do the reverse by exposign public methods in the silverlight controls that you want your javascript in the page. You can mark it with a Scriptable attribute, and register the Scriptable object. Then you can call the FootballData object you registered and call the method marked with the Scriptable.

Question: Would you get a Javascript error before the Silverlight control is loaded? Yes you will, you can check a method to see if the silverlight control is loaded.

You can use Permalinks, integrate forward / backward navigation, etc. We support both simple and complex types across (complex type support not ready yet).

Question: Can you render HTML within Silverlight control? Absolutely. Someone build an HtmlTextBlock for Silverlight, to render HTML within Silverlight (needs to be well formatted) and you can compose HTML and Silverlight controls in the same space.

Demo: HTML interaction.

The title is a silverlight control, the textbox and button are standard html. Enter text and click the button, the sliverlight control update its text by hooking the click event of the html element and updating the TextBlock element within it.

Question: What if you want to gain access to the ClientID? You can for example embed the value as a hidden field or a javascript value.

Demo: Pure HTML page

All the UI is done in HTML. Enter text, click the button, the text appears. What is being used is to hook the button click DOM event, and call silverlight from it. From within silverlight, the .net code creates an html element and adds it to the DOM page. You could then leverage network calls from Silverlight to update data in your html page.

You can also use OpenFileDialog. Often in HTML pages people ask how to add several files in one go. For mutliple files you need several input elements, so you have to do them one at a time. With the OpenFile support in HTML you can't have access to the file from the client. You have to upload to the server, then the client goes back to the server through AJAX or other for the client to consume. The OpenFileDialog makes things easier. You can select single or multiple files, provide filters, dialog, and get what the user sleected (OK, Cancel. etc)

You cannot have access to the original file path or the default path. The user has to explicitly find the phone.

Question: Can it be persisted locally after loaded? We don't give you the path to the file. Can we see the file size: Yes, as well as the file content type.

Let's create a text file. Open a sample, open a file dialog filtered for text files, select the document, the client reads the file and puts it into the silverlight control, the server didn't get hit. You could've done selection of multiple files too.

The code has a OpenFileDialog, with a DialogResult enumeration (very similar to WPF), then reading the content.

What about the network? Same as the .net framework. There's HttpWebRequest (called BrowserWebRequest), which lets you get byte streams in the alpha.

Question: Using local URI? Will throw a security exception. The browser is responsible for cross domain calls. Is there Asynchronous? Yes absolutely, there's a demo.

There's a button, we select an image and upload it to the server. Picture of Scott's sister before the ceremony.

You can also use the web services stack. Instead of using raw HTTP you can create a proxy for JSON (supported in the alpha) and WCF & SOAP (coming soon).

Question: Cross domain? Not supported now, but policy file on the server to give rights supported for release. You can now call any service and integrate it, which opens new opportunities. Will the WCF support will be Duplex? Don't know. Send me an email I'll find out.

You can do an async callback when downloading, prevents the client freezing.

Demo: Two buttons, one call GetMessage method synchronously, the other one asynchronously, which will call another method when downloading is done, freeing your UI thread. Synchronously, the button is frozen while downloading, whereas asynch everything stays responsive.

Question: Is there a need to marshal to the correct thread? For async no because we do it for you. If you use the background thread, you don't marshal but need to let the background thread know. Is it in there? No we pulled it out because it didn't work consistently on all browsers, one of them didn't work so we pulled it out. We won't ship this new thread model when we fix it. Do services call still use the borwsing stack? For Http traffic we still use that so we integrate with the cache. For browsers you can increase the number of connections to a server. There's also sockets support coming. System.Net will work in the sandbox in the future, even though it doesn't work for WPF in xbap.

For anyone building on Amazon S3 servers you'll be able to upload files there. It's great so you don't have to have a server farm to upload your data. You can do most work on the client, a few web servers on the backend, and pay as you go.

Once you download data, you can use the IE / Safari / Firefox cache. But you can also use Isolated Storage as a giant cookie. It's a feature in .net today [EDIT: been since .net 1.0!]. You can read and write from it. There's a 1MB limit for silverlight right now, but we may give the possibility for the user to change it.

Question: Can you have access to other isolated storage from other applications? For the alpha you get a separate store. The plan is for it to be shared per site. Can users turn on and off? The user can clear the cache which clears the IsolatedStorage. We should give the users a way to not allow IsolatedStorage. That's what consumers want.

Silverlight provides LINQ support, but you cannot use LINQ to SQL. This is not using LINQ but the SQL technology, LINQ is a general purpose query language. We'll provide LINQ to XML in the final release, so you can search and sort your xml data you download. We provide LINQ to objects right now. Because LINQ lets you provide your own dataproviders, you'll see LINQ to Flickr, LINQ to S3, which will get translated, so you don't have to know the actual web services to access these services.

Question: Is there a schedule for a refresh? There's no public date for that at the moment. Next milestone will have a lot of low level plumbing to get the layout system and core text input, but there won't be a lot of surface features appearing. It will be later this year but we don't know when yet. We're thinking of not doing a refresh on this infrastructure milestone. Is there a way to have a transform over time (animation support).

Is there support for animation? Demo of animating a transform over time in Blend, which works for Silverlight. You can change the transform type you want, you can loop it, reverse, etc.

The other nice thing from an architecture perspective is that with the increase in multiple core, it's hard from the UI. Silverlight ahs built-in in multicore support, everything gets partitionned on different cores automatically. All the graphics and animations get calculated on separate threads. That means better performance.

Is there a draw API? No we have a retained mode graphics system, so we draw objects on the screen. On multicore and having retained mode, we know how to redraw without you having to write sync, and we know how to draw it efficiently without having to ask you. We can choose to go hardware accelerated without breaking your code. BitmapEffects are not in 1.1, we've not decided to include them or not.

Is there a notion of frame rate? There's a notion of a frame rate, there's an api for that. But because of keyframes this is probably not reliable.

Which platforms are you supporting? Win200, XP, 2003, Vista, Tiger and Leopard, potentially Panther for Microsoft, Novell does Linux called moonlight on redhat, freebsd, solaris, and mobile devices will be announced. Safari and firefox on the max, Firefox and IE, with Opera planned on windows.

Technorati Tags: