Getting started with Silverlight BluePrint

The first Silverlight-for-SharePoint samples have been released, with doco, sample code, sample webpart and videos showing how to install.

All of the (6) samples available have both Silverlight 1.0 and 2.0 versions - I thought I’d go for the NEW version, even though it’s BETA (only a dev/play VM anyways).

The first of these samples is the “HelloSilverlight” control, containing the usual Hello World control (in 1.0 and 2.0 flavours)

There is also a “container” WebPart, which can be used to host a XAML file, or XAP file (new 2.0 version).   This would be very useful - kinda like a Silverlight Content Viewer.

Here’s what you get in the package (FOUR zip files) :

1. HelloSilverlightSampleDoc

Contains a DOCX for the WebPart projects.   The sample consists of two projects: one for the Silverlight 2 application and one for the SharePoint Web Part.

There are TWO files (DOCX) - one each for the Silverlight 1.0 and 2.0 versions.

2. HelloSilverlightSampleSetup

Contains SETUP.EXE files for

  • Silverlight 1.0 Hello World WebPart 
  • Silverlight 2.0 Hello World WebPart
  • Silverlight container (SilverlightPart) WebPart

3. HelloSilverlightSampleSource

Contains the source code for the THREE WebParts.   For the 1.0 and SilverlightPart, there is a single project with the necessary CS files & lots more.

For the 2.0 version, there are actually TWO projects : the Silverlight 2.0 application project - and the WebPart to host the Silverlight application.

4. HelloSilverlightSampleVideo

Again - THREE files, showing how to install, and activate each of the WebParts - and then add to the page.  Nothing special - but there are some cool bits within the video clip for the SilverlightPart control.

NB.  All of the SIX sample projects have this same structure - DOCO, SOURCE, SETUP and VIDEO - very easy to get started and see how it works.

OK - so I ran the install’er like shown in the video - but when attempting to add the WebPart to the page, I get the following error :

image

It seems like the samples (setup) are “not enough” - and there are some additional steps required :

If you just install the Silverlight BluePrint samples onto a SharePoint Server, they will not work because the following dependencies must be installed:

Silverlight plugin (must be installed on the server !)

Silverlight 2 Software Development Kit Beta 1 (40.0 MB)

GAC the System.Web.Silverlight.dll - copy from C:\Program Files\Microsoft SDKs\Silverlight\v2.0\Libraries\Server to C:\windows\assembly

Check the /ClientBin/ directory of your SharePoint site for the existence of Silverlight.js.   If missing (YEP !), copy it from C:\Program Files\Microsoft SDKs\Silverlight\v2.0\Tools.

Register the MIME type for file extension .XAP in IIS - NB. didn’t need to do this for Windows Server 2008 (IIS-7)

Perform an IISReset - should now be able to add the SilverlightPart (!)

Thanks to Ian Morrish for the above tips/links - cool stuff !

Finally - HELLO WORLD ?!!?   Nooooo !!    The error no longer appears - but just shows as an empty WebPart box.

image

*hhmmm*   Will have to investigate some more.   It is a BETA version after all !!

Anyone been able to get the XAP version working ?   (ie. Silverlight 2.0)

UPDATE (26/03/2008):

Have found some things that may be the cause/solution, after cracking open the code within Visual Studio 2008.

Script (INSTALL.BAT)

(1) Need to change some of the scripts that refer to “SL.HelloSilverlight20″ - these should be “SL.HelloSilverlight2″ - without an additional zero (ie. 2 not 20)

(2) Also have to update the file locations for CLIENTBIN and GACUTIL - that’s for MY environment, of course

(3) Lastly, ensure the URL being activated is correct - not http://silverlight.litwareinc.com

I was still getting an error on build, so I removed the POST-BUILD step - and run the PACKAGE.BAT - and then INSTALL.BAT files myself.

Solution Definition File

Interestingly, there is a bug/error in the PACKAGE step - which bundles up all files using the \Solution\wsp_structure.ddf file.

If you open the file in VS-2008, the last line is wrong…>

Template\Images\BluePrint\silverlight.jpg

should started with “12\” …>

12\Template\Images\BluePrint\silverlight.jpg

Successful deploy

I can now step through/into the code for the WebPart - and ensure that each line is being executed - but STILL - no output !!

It looks like the Silverlight stuff and all JavaScript is being rendered out (from view source) - but isn’t displaying the control.

*phew*   Will keep looking - something will pop out sooner or later…!

12 Comments so far

  1. David Marsh on March 27, 2008

    I had all the same problems you had then I starting looking at every file and looked at the ClientBin folder in the SL.SharePoint.HelloSilverlight2 project and noticed the date created on the xap file was a few weeks old so I cracked open the xap file and compared the SL.XAML.HelloSilverlight.dll in there with the SL.XAML.HelloSilverlight.dll file in the SL.XAML.HelloSilverlight2 project and noticed they were different sizes so I dropped the newly compiled xap file from the SL.XAML.HelloSilverlight2 project into the SharePoint ClientBin folder and success, the Silverlight stuff appeared. I hope this helps or if it is unclear email me and I can try and clarify. Thanks for your tips, especially the missing Silverlight.js file.

  2. [...] The Grumpy Wookie’s post on same subject [...]

  3. zaher on April 8, 2008

    i’ve performed all the previous steps but still the empty webpart appears

  4. Evelyn on April 8, 2008

    I’ve tried everything written on this page an an this page: http://www.u2u.info/Blogs/Patrick/Lists/Categories/Category.aspx?Name=Silverlight%20BluePrint
    …after recomiling the .xap file with VS2008 the testpage.htm works fine. unfortunately in sharepoint the webpart is still empty :(
    any ideas?

  5. RichardI on April 23, 2008

    I was getting the following Javascript error in IE when trying to view the Silverlight 2.0 version of the HelloSilverlight control in SharePoint (the 1.0 control worked fine): Sys.InvalidOperationException: InitializeError error #2105 in control ‘ctl00_…_ctl00′: Failed to load pre-requisites for the application.

    I tried the fix suggested by David Marsh, copying the SL.XAML.HelloSilverlight2.xap file from SL.XAML.HelloSilverlight2\ClientBin to SL.SharePoint.HelloSilverlight2\ClientBin\SL.HelloSilverlight2 and then ran the install.bat file, and it cleared up the issue. Looks like nothing in the solution copied the updated .xap file to the folder referenced by the install.bat file, so it was picking up an outdated copy. Nice catch David!

  6. Nigel Watson on April 28, 2008

    Richardl - thanks for the pointer - this fixed the blank silverlight webpart issue for me (the updated XAP isn’t being copied into the clientbin directory by the default install .bat file. I also had to make all of the other changes to the paths/URLs etc in the install.bat file to point at the correct locations on my server. It seems to be working fine now.

  7. Andre Stene-Larsen on May 6, 2008

    I had the exact same problem. First I tried to fetch the .xap file directly through my browser, this returned a 401 access denied so I fixed that. Still the Silverlight web part would not show. Then I tried to inject some html pointing directly too my .xap file. I know it’s a workaround, but you can use the content editor web part of sharepoint and inject this html

    This works, so it must be something with the scripts thats loading the silverlight plugin I guess..

    html, body {
    height: 100%;
    overflow: auto;
    }
    body {
    padding: 0;
    margin: 0;
    }
    #silverlightControlHost {
    height: 100%;
    }

    function onSilverlightError(sender, args) {
    if (args.errorType == “InitializeError” ;) {
    var errorDiv = document.getElementById(”errorLocation”);
    if (errorDiv != null)
    errorDiv.innerHTML = args.errorType + “- ” + args.errorMessage;
    }
    }

  8. Andre Stene-Larsen on May 6, 2008
  9. Andre Stene-Larsen on May 6, 2008

    I am trying again..

  10. Andre Stene-Larsen on May 6, 2008

    Hmm, no luck in posting the html markup.. Well, at your development computer take a look in the clientbin folder of your silverlight project. You should find a testpage.html file, this file contains the markup. Just modify the source of the object tag and you should be fine.

  11. Jules on May 7, 2008

    How do I get the System.Web.Silverlight.dll Assembly into the Global Assembly Cache (GAC) ?

    I have installed the VS2008 Tools for Silverlight 2.0, and the SDK, and yet the assembly still not in the Cach (So it is does not referenced in Silverlight the Web.config File either)

    I tried GACUtil, but this tool does not appear to be recognised. Where is GACUtil these days, and do I need to Strong Name the System.Web.Silverlight.dll myself.

    Silverlight Web parts, even with theBluePrints, still a very painful experience.

  12. dkarantonis on May 7, 2008

    Hi Jules,

    from the start menu, go to Administrative Tools->Microsoft .net Framework 2.0 Configuration and select the ‘Add assembly to the GAC’. I don’t think that you have to strong name the assembly.

    Anyway, i still haven’t managed to display the web part on my MOSS page. I’ll try to hack the source code files as mentioned on the above comments and make it work.

    All these concern the Hello World 2 Silverligth Web part? What about the others…?

Leave a reply