Even a chimp can write code

Thursday, March 18, 2010

Stepping outside the browser with Silverlight 4

Thanks to all those who attended the talk "CL10 - Stepping outside the browser with Silverlight 4" at the Mix 2010 conference or caught it via the recorded session online. I talked about the evolution of Silverlight into a general purpose development platform, far away from its origins as a browser plugin. I walked through features that light up outside the browser through our deliberate nested doll design approach - both in Silverlight 3 and continuing into Silverlight 4 now. I also talked about trusted apps and emphasized how important getting the right user experience and removing friction from app deployment was to us in the Silverlight team.

Here is the slide deck from the talk. Source code for the basic sandboxed app is archived here; and code for the trusted app can be found here. Hope you find it valuable.

The Q&A session at the end was very useful. I appreciate all the interest in this space and was happy to learn of the apps people were building. We could only get here "with a little help from our friends" in the ecosystem. We can continue that conversation on this blog, or you can send me email (ashsh).

Update: as a postscript, the slide deck I linked to here looks different from the one I used in the talk. Due to "technical difficulties" the podium machine had an older copy of the deck from one of my previous uploads, and I only found out once I was into the talk (silly me for not checking). So if I looked like I crapped a brick at the beginning, now you know why. Live and learn.

Labels: , , ,

Email this | Bookmark this


  • Hello,

    I have used the TutorialXCPHost C++ code a lot get and understanding of how to directly host SL. For SL 4 are there new host options that allow you to turn on COM Automation support from the SL app?
    SL 3 options for example:
    /*XcpHostOption_FreezeOnInitialFrame = 0x001,
    XcpHostOption_DisableFullScreen = 0x002,
    XcpHostOption_DisableManagedExecution = 0x008,
    XcpHostOption_EnableCrossDomainDownloads = 0x010,
    XcpHostOption_UseCustomAppDomain = 0x020,
    XcpHostOption_DisableNetworking = 0x040,
    XcpHostOption_DisableScriptCallouts = 0x080,
    XcpHostOption_EnableHtmlDomAccess = 0x100,
    XcpHostOption_EnableScriptableObjectAccess = 0x200,*/

    The reason is simple: sllaunch.exe doesn't give me enought control over. I need a custom host:
    1. The windows chrome, always on top, dissallow certain key strokes etc.
    2. Registry-less COM. I need to deploy on desktops that aren't logged in as admin's. Thus, cannot registry a COM control. By having my own EXE/Process i can use registry less COM. yes I need to get to the hardware, the serial ports in this case.

    3. Why go to all this trouble? No gaurantee of anything greeater than .NET 2.0 on the hardward. SL is a small deploy and more current BCL with C# 4.0, dynamic keyword, Linq etc. XDocument too. What does this also allow? Carefully construcuted code that runs in my data center and my SL client.

    4. On a machine that is used by multiple users (separate windows logons). Installing an OOB app for each users (local settings), or some messy shell folder redirection group policy is simply to messy. I need an XCOPY deploy that works for a least priveleged user. All they need is access to a shared directory on the machine.


    By Anonymous Anonymous, at March 18, 2010 at 4:48 PM  

  • First, I wouldn't recommend taking the approach you're considering. There is a pile of engineering involved, with lots of little gotchas; and if you need this to scale to other OSes you'll need to write platform specific code. Silverlight makes all that easy for you.

    However to answer your question: you can use the new host option XcpHostOption_EnableElevatedPermissions to instruct Silverlight to run trusted apps. Your XAP - of course - needs to have all the markings of a trusted app, with that choice having been expressed at development time.

    Further if you want an easier way than reg-free COM, your host can hook for the CreateObject/GetObject calls via XcpHostOption_HookGetComAutomationObject. It needs to implement , IXcpControlHost3::GetComAutomationObject. The signature is:
    HRESULT GetComAutomationObject([in] BSTR bstrProgId, [in] DWORD dwFlags, [out, retval] IDispatch** ppDisp);

    The flags will currently be one of
    and are used by the host to detect whether they are getting a GetObject or a CreateObject call.

    The host can return S_FALSE to indicate that the default processing for that Create/GetObject calls should occur (i.e., the runtime does what it would normally do if there was no native host). The host will return S_OK if it successfully provided a COM Automation object. Otherwise, any failure return code will be bubbled up to the managed API call that initiated the operation.

    There is no ability for the native host to wrap the default Create/GetObject processing.

    This will all be in the documentation in MSDN. Hope this helps. Good luck.

    By Blogger Ashish Shetty, at March 24, 2010 at 6:17 AM  

  • Even a chimp can write code.. hmm.. Definitely not with Visual Studio IDE... Eclipse is way better than VS..

    By Anonymous Anonymous, at December 23, 2010 at 8:44 AM  

Post a Comment | Home | Inference: my personal blog