Microsoft Desktop Player

MSDN TechNet Flash has announced Microsoft Desktop Player, now it is in Beta, it can be accessed through the official website which is Silverlight based:

I also installed the desktop version, the desktop version is not a Silverlight OOB, instead, it is a traditional Winform, see screenshot below:

Click to see large image

Click to see large image


Microsoft ALWAYS offer developers strong and great support/guidance, this point is really respected!

Study EVM (Earned Value Management) – 2

Once the CPI/SPI were calculated at some time-stamp, project manager should be deeper analyses, he need to predict the future cost:

ETC (Estimate To Completion)

Then EAC (Estimate At Completion) = AC + ETC

How to calculate ETC based on current situation (EV/AC/PV and SPI&CPI), there are usually three methods:

  1. Regardless of current Schedule/Cost Performance Index
    This way is simple, I don’t care what’s happened, EAC = BAC + EAC – AC, in other words, project team is confident to finish the project below estimated cost.
  2. Estimated based on current CPI
    This way is straight-forward, review current CPI and estimate future cost based on it:
    EAC = AC + (BAC -EV)/CPI = BAC / CPI
  3. Consider both CPI/SPI impact
    I think this way the rationalist one, it consider both SPI and CPI, in additional, PM could give a “weight” to SPI or CPI according to his/her experience and judgement, so the formula is:
    EAC  = (BAC – EV) / (CPI * SPI)

No matter which method PM chooses, as long as the calculated/predicted EAC is not acceptable, then it is an “early warning” to the team.

Even more, PM need calculate TCPI, the content below as copied from EVM on Wikipedia, it is very clear for me.

The To Complete Performance Index (TCPI) provides a projection of the anticipated performance required to achieve either the BAC or the EAC.

For the TCPI based on BAC (describing the performance required to meet the original BAC budgeted total):
TCPI_{BAC} = { BAC - EV \over BAC - AC }
or for the TCPI based on EAC (describing the performance required to meet a new, revised budget total EAC):
TCPI_{EAC} = { BAC - EV \over EAC - AC }
Independent estimate at completion (IEAC)
The IEAC is a metric to project total cost using the performance to date to project overall performance. This can be compared to the EAC, which is the manager’s projection.
IEAC = \sum AC + { \left( BAC - \sum EV \right) \over CPI }

Wish I success, again!  +U!

Study EVM (Earned Value Management) – 1

During the past few days I was studying Project Time Management in PMBOK, for preparing the upcoming PMP exam on 4th December 2010, while I spent a few hours on understanding/mastering EVM, I log my memory hereSmile

EVM stands for Eearned Value Management, it is a complementary for Critical Path Method schedule management, its purpose could be described as “What did we get for the money we spent?” the definition of is in Wikipedia is below:

Earned value management (EVM) is a project management technique for measuring project progress in an objective manner. EVM has the ability to combine measurements of scope, schedule, and cost in a single integrated system. When properly applied, EVM provides an early warning of performance problems. Additionally, EVM promises to improve the definition of project scope, prevent scope creep, communicate objective progress to stakeholders, and keep the project team focused on achieving progress.

There are three fundamental glossaries in EVM, they are:

  • PV Plan Value (also called BCWS – Badget Cost for Work Scheduled)
  • AC Actual Cost (also called ACWP – Actual Cost for Work Performed)
  • EV Earned Value (also called BCWP Badget Cost for Worked Performed), so
    EV = BAC (Budget At Completion) * [Finished work]%
    EV formula from Wikipedia:


For simple and straight-forward, in my understanding:

  • PV is on a specified timestamp, what is the planed budget.
  • AC is on a specified timestamp, what is the actual cost.
  • EV is on a specified timestamp, how much percent of work has been done while how much cost was expected.
    During the project implementing process, Program Manager tracks the schedule and cost using EVM, and calculate SV&SV, SPI&CPI, they are:

SV Schedule Variance
SV = EV – PV
CV Cost Variance
CV = EV – AC

SPI Schedule Performance Index
CPI Cost Performance Index

I take a simple example for better understanding, assume I am managing a 10 days project code name “Lambda”, Lambda project has a BAC of $100, and the detailed project schedule was determined below:

Day# 1 2 3 4 5 6 7 8 9 10
Budget $10 $10 $10 $10 $10 $10 $10 $10 $10 $10

The scenario is at the end of day 3, I (PM) called up team member and held a meeting to track status, we found:

We got 40% of the entire work done, on the other hand, we’ve already spent $60, based on this fact, I (PM) will get to know:

PV: 3 days past, initially we planed/supposed to spend $30 according to the schedule, so PV=30.
AC: We’ve spent &60, so AC=60.
EV: we finished 40% of work, initially we planed/supposed to spend $40 to get 40% work done, so EV=40

OK, then:

SV = EV – PV = 40 – 30 = 10, greater than 0, it is good, we are ahead scheduleSmile
CV = EV- CV = 40 – 60 = -20, smaller than 0, it is not good, we are overspending moneySad smile

SPI = EV/PV = 40/30 = 1.3 > 1 greater than 1, good.
CPI = EV/CV = 40/60 = 0.66 < 1, smaller than 1, not good.

+U+U to myself, I put a flag here, I believe I will pass the exam!


EVM on Wikipedia

EVM official web site

Elevated trust in Silverlight 4


In Silverlight 4, Out Of Browser with elevated permission is significantly improved, now the OOB application has more privilege in accessing system resources such as the ability of accessing Isolated Storage, manipulating COM objects, access local registry entries, or even invoke Microsoft Speech API to phonate.

Essentially, to achieve this, the main improvements are:

  1. Microsoft gives Silverlight 4 OOB applications ability to request elevated trust.

    From Trusted Applications
    You can configure out-of-browser applications to require elevated trust. After installation, these trusted applications can bypass some of the restrictions of the security sandbox. For example, trusted applications can access user files and use full-screen mode without keyboard restrictions.

  2. A new concept coming from .NET 4.0 called “late binding”, the C# key word: dynamic could be use to declare a undetermined type at build time, during runtime, Microsoft.CSharp.RuntimeBinder will do dynamically building.


My post is going to concentrated discuss about elevated trust, so read the articles below if you have any issues about creating OOB and request elevated permission.

How to: Configure an Application for Out-of-Browser Support
How to Configure your Silverlight App to run in Elevated Trust Mode

I developed a simple Silverlight OOB demo, it will access local system resources including:

  • Let user choose some file(s) and then copy them to isolated storage.
  • Access isolated storage enumerate all files.
  • Create a txt file under drive C: by invoking “Scripting.FileSystemObejct”, as well as read its content back.
  • Write registry entry under HKEY_CURRENT_USER, read registry entry under HKEY_LOCAL_MACHINE, by using “WScript.Shell”.
    Note: Silverlight OOB application will NOT have write permission to HKLM, it only have read permission.
  • Run another executable files located on the system by using “WScript.Shell”.
  • Phonate a sentence user input into the textbox.


After installing on the system, its UI is shown below (I know it is really poor… SorrySmile):


The elevated permission ONLY enabled in Out Of Brower scenario, so in our Silverlight application we need check whether currently it is running out of browser:

    // Access local file, registry, COM, etc.

In additional, to invoke COM objects, we need check whether AutomationFactory is available:

if (AutomationFactory.IsAvailable)

OK here we go to see the code behind to implement elevated permission.

1. Clicks on Button – “Copy File to Isolated Storage acces”, a File open dialog will popup, screenshot below:
Code behind to open file dialog:

            OpenFileDialog dlg = new OpenFileDialog { Filter = "All files (*.*)|*.*", Multiselect = true };
            var dlgResult = dlg.ShowDialog();

Read selected file(s) and copy them to isolated storage:

                IsolatedStorageFile iso = IsolatedStorageFile.GetUserStoreForApplication();
                foreach (FileInfo file in dlg.Files)
                    using (Stream fileStream = file.OpenRead())
                        using (IsolatedStorageFileStream isoStream =
                            new IsolatedStorageFileStream(file.Name, FileMode.Create, iso))
                            // Read and write the data block by block until finish
                            while (true)
                                byte[] buffer = new byte[100001];
                                int count = fileStream.Read(buffer, 0, buffer.Length);
                                if (count > 0)
                                    isoStream.Write(buffer, 0, count);

Code behind for “Load file from isolated storage”:

var isoFiles = from files in IsolatedStorageFile.GetUserStoreForApplication().GetFileNames()
                           select files;

2. Create a text file at “C:\WayneTestSL4Fso\WayneTest.txt”, please note: if you use System.IO.File to do such operation you won’t success, I guess it is because elevated trust is still not directly implemented in a lot of managed assemblies. Here in my demo I used Scripting.FileSystemObejct:

        private String folderPath = "C:\\WayneTestSL4FSO";
        private String filePath = "C:\\WayneTestSL4Fso\\WayneTest.txt";

        using (dynamic fso = AutomationFactory.CreateObject("Scripting.FileSystemObject"))
            if (!fso.FolderExists(folderPath)) fso.CreateFolder(folderPath);
            dynamic txtFile = fso.CreateTextFile(filePath);
            txtFile.WriteLine("Some text...");

P.S. While I first time used “dynamic” keyword within a using statement, I was a little bit surprised, I can simply try to dispose a dynamic object without checking whether it has implemented IDisposible, hence I tried run using (dynamic x = 8 ), then I got thisSmile:

OK, let’s back to the code implementation for reading the text file I just created,

                var fileContent = String.Empty;

                using (dynamic fso = AutomationFactory.CreateObject("Scripting.FileSystemObject"))
                    dynamic file = fso.OpenTextFile(filePath);
                    fileContent = file.ReadAll();


3. Registry write/read, please note: we can only have registry write permission to HKCU NOT HKLM, we have read permission to HKLM entries.

                using (dynamic wScript = AutomationFactory.CreateObject("WScript.Shell"))
                    // Only has write permissin to HKCU
                            "SomeStrValue", "REG_SZ");
                using (dynamic wScript = AutomationFactory.CreateObject("WScript.Shell"))
                    string dotNetRoot =

4. Run another local application

                using (dynamic wScript = AutomationFactory.CreateObject("WScript.Shell"))
                    //Refer WScript.Run at:
                    wScript.Run("iexplore", 1, true);

Note 1: WScript.Shell.Run method can accepts not only executable files, but also accepts *.bat, Windows Script Host files (*.vbs, *.js) or PowerShell script files, etc.
Note 2: Intention to elevate more permission by running another exe or script file definitely won’t success, for example, if I try to invoke AccessKHLM.js below from my OOB application I will get a 80070005 error code that indicates access denied:

var WshShell = WScript.CreateObject("WScript.Shell");

WshShell.RegWrite("HKLM\\Software\\WayneTestValue\\", 1, "REG_BINARY");

If you double click the Demo.js you will success since you are a Windows Administrator, while “Silverlight-based applications run in partial trust, which means they run within a security sandbox“, for more information please refer Trusted Application.

5. Phonate a sentence

    using (dynamic speechApi = AutomationFactory.CreateObject("Sapi.SpVoice"))

6. Code to implement close button “X” appear on the upper-top corner.

    using (var wScript = AutomationFactory.CreateObject("WScript.Shell"))
        wScript.Run(@"cmd /k taskkill /IM sllauncher.exe & exit", 0);

This is a little bit tricky, I searched a while on google and found a great article Programmatically exit Silverlight 4 Out-of-browser application.  Essentially the code invokes WScript.Shell and runs cmd and terminate sllauncher.exe, so that our OOB process got killedSmile with tongue out.


With elevated trust for Silverlight OOB applications, we can do much more than ever, it give more confidence to develope Enterprise business applications using Silverlight technology, yesterday I saw Scott Guthrie posted a blog talking about Silverlight, he mentioned Microsoft will absolutely continue work hard on Silverlight for Enterprise Businees Applications (both online and OOB).

Source Code Download


How to: Configure an Application for Out-of-Browser Support

How to Configure your Silverlight App to run in Elevated Trust Mode

Silverlight Tip of the Day #19: Using Isolated Storage

File Explorer using Silverlight 4 COM Interoperability

WshShell Object