Blank Web Parts with latest Silverlight 2 release from Microsoft

Nov 19, 2008 at 9:29 PM
I have followed the instructions of SharePoint Silverlight 2 blueprint guidance documents, however all my blueprint web parts show as blank in the SharePoint site.  How can I get these web parts to work after having the latest Silverlight 2 release from Microsoft installed on the server?
Dec 4, 2008 at 7:50 PM
Edited Dec 4, 2008 at 10:35 PM
i am having this issue as well.

i can build and deploy the webparts, see that they are activated in the site collection, add them to a page and publish it, but it is not visible. if i right-click in the blank area where it should appear, i see that the silverlight control is there (context menu for silverlight).

i have silverlight controls that i have developed that are working just fine in sharepoint, sitting right next to these examples that are borked. i noticed that the sample that is not working looks like this in the source for the page:

<script type="text/javascript">
//<![CDATA[
Sys.UI.Silverlight.Control.createObject('ctl00_ctl11_g_516a7d85_d0ad_4cee_8ce5_7c861109348d_SLHelloWorld_parent', '\u003cobject type="application/x-silverlight" id="ctl00_ctl11_g_516a7d85_d0ad_4cee_8ce5_7c861109348d_SLHelloWorld" style="width:300px;">\r\n\t\u003ca href="\u003cimg">http://go2.microsoft.com/fwlink/?LinkID=114576&amp;v=1.0">\u003cimg src="http://go2.microsoft.com/fwlink/?LinkID=108181" alt="Get Microsoft Silverlight" style="border-width:0;" />\u003c/a>\r\n\u003c/object>');
     //]]>
</script>

the difference i see is that in my silverlight control that is rendering properly, the type is "application/x-silverlight-2". i am wondering if that is the issue, and if so, how to make it so that the script gets written properly?

EDIT: more research...

My other silverlight control is in a user control, which I placed on a master page. The primary difference with that one is that it is created like this:

 

    <asp:Silverlight ID="SLManageProfile" runat="server" Source="~/ClientBin/Debug/ManageProfile.xap"

        MinimumVersion="2.0.30523" Width="1px" Height="1px" PluginBackground="Transparent"

        AutoUpgrade="true" HtmlAccess="Enabled" ScaleMode="Stretch" Windowless="true"

        Style="position: absolute; z-index: 4;" />

 

As opposed to in the webpart, where it is created in the code-behind like this:

 

System.Web.UI.SilverlightControls.Silverlight ctrl = new System.Web.UI.SilverlightControls.Silverlight();

 

I have the same version of the DLL everywhere on my machine… in the GAC, referenced in both projects, in the bin of the Sharepoint site… so… kind of stumped. Help! =p

Dec 5, 2008 at 9:44 PM

I figured it out. Turns out it had nothing at all to do with the way the script was being written to the page... I guess application/x-silverlight is just fine, even for Silverlight 2.

In the SharePoint blueprint project that contained the sample I was working with, I had the wrong path set up in my Silverlight object's 'Source' property:

 

        protected override void CreateChildControls()
        {
            base.CreateChildControls();

            System.Web.UI.SilverlightControls.Silverlight ctrl = new System.Web.UI.SilverlightControls.Silverlight();
            ctrl.ID = "SLHelloWorld";
            ctrl.Source = SPContext.Current.Site.Url + "/XAPS1/SL.XAML.HelloWorld.xap";
            ctrl.Width = new Unit(400);
            ctrl.Width = new Unit(300);
            Controls.Add(ctrl);
        }
 I had changed XAPS to XAPS1, but I needed to delete all temp files in my browser in order for it to work... so I kept chasing down perceived problems that didn't exist. Hope this helps someone!
Dec 11, 2008 at 10:42 AM

I'm having sort of the same problem... only it's just the SL.XAML.MediaViewer that doesn't show... all the other Silverlight application show up fine.

My question is... how can I debug or troubleshoot this? is there anyway to narrow down the cause of the problem?

I've confirmed that the XAP is in the correct place and it's accessible, I've gone through the web.config to see if I had missed something, I've deleted temp files and cookies, event viewer is empty... any other suggestions?

Thanks in advance

Dec 12, 2008 at 8:51 PM
ditto the same problem. Also like homerun57 I have checked the XAP doc lib in the root of the site. SL.XAML.HelloWorld and SL.XAML.MediaViewer files are both present in the library. The web parts do load, but nothing in the space provided... I too am interested in a method to T-Shoot this.

ditto appreciation in advance.
Jan 6, 2009 at 4:06 PM
I have exactly the same problem as robinMagenic... My doclib  SL.XAML.MediaViewer is present in the library in the good position. Moreover, when i deploy the solution it's ok .. I modify my web.config correctly and i try differents MIME TYPE for silverlight (good version) And I still have a Blank Webpart!!:(
What is the problem whith a blank webpart using Mediaviewer? My config is Silverlight 2.0, Server 2008, MOSS SP1
Thanks in advance....
Jan 14, 2009 at 11:53 AM
There may be different reasons for the blank webpart. If you are using the RTM release of this blueprint (and you should be, since as of this writing, RTM or the 11/30 release is available), the very likely reason is that you have NOT uploaded XAP file into http://<server name>/<site hierarchy>/RTMXAPS. Where did I get RTMXAPS path? From line 38 in SLHWRTM.cs:

ctrl.Source =
SPContext.Current.Site.Url + "/RTMXAPS/SL.XAML.HelloWorldRTM.xap";

 

Jan 26, 2009 at 10:27 PM
I'm also experience the same problem but manged to fix it by throwing the XAP file onto the filesystem at 

C:\inetpub\wwwroot\wss\VirtualDirectories\<Port>\Clientbin

and then modifying my code from 

ctrl.Source = SPContext.Current.Site.Url + "/XAPS1/SL.XAML.HelloWorld.xap";

to 

ctrl.Source = "~/Clientbin/SL.XAML.HelloWorld.xap";

For some reason, if the XAP file is in SharePoint like in a document library, it is unable to find the XAP file. I know the XAP file exist at the location since I paste the URL directly in the browser and it attempted to download the file.

Has anyone else seen this behaviour?

Feb 9, 2009 at 3:54 AM
I have experienced the same problem and resolved it in the same way as you, chamt. For some reason, the document library is not recognized.
Mar 14, 2009 at 10:14 AM
I also encountered with problem. No silverlight on web part.
Apr 17, 2009 at 9:37 AM
I had this problem too and it took me ages to fix.

In the end I reckoned it was my web.config that was the problem so I created a new silverlight web application project and copied the entire web.config from it section by section into the web.config in my base wss site under virtualdirectories/80.

To my shock it actually worked. I had been trying to pick my ay through the changes as some of the additions in the web.config on codeplex obviously didn't apply to me. The good thing about this way is you know you have everything. Initially it looked a bit intimidating but it wasn't as bad as I thought. You can clearly see the sections so you just work your way down the entire file and copy out the contents of each section. I have highlighted each section head in 14pt to make it a bit clearer.
-------------------------------------------------------------

<?xml version="1.0"?>
<configuration>

<configSections>

<sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
<sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="Everywhere" />
<section name="profileService" type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" />
<section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" />
<section name="roleService" type="System.Web.Configuration.ScriptingRoleServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" />
</sectionGroup>
</sectionGroup>
</sectionGroup>
</configSections>

 

 

<appSettings/>
<connectionStrings/>
<system.web>
<!--
Set compilation debug="true" to insert debugging
symbols into the compiled page. Because this
affects performance, set this value to true only
during development.
-->

<compilation debug="false">

<assemblies>

<add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Data.DataSetExtensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
</assemblies>

 

</compilation>
<!--The <authentication> section enables configuration of the security authentication mode used by ASP.NET to identify an incoming user. -->
<authentication mode="Windows" />
<!--The <customErrors> section enables configuration of what to do if/when an unhandled error occurs during the execution of a request. Specifically,
it enables developers to configure html error pages to be displayed in place of a error stack trace.

<customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
<error statusCode="403" redirect="NoAccess.htm" />
<error statusCode="404" redirect="FileNotFound.htm" />
</customErrors>
-->

 

<pages>

<controls>
<add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add tagPrefix="asp" namespace="System.Web.UI.WebControls" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
</controls>
</pages>

 

<httpHandlers>

<remove verb="*" path="*.asmx"/>
<add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" validate="false"/>
</httpHandlers>

 

<httpModules>

<add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>

</httpModules>

 

</system.web>

<system.codedom>
<compilers>
<compiler language="c#;cs;csharp" extension=".cs" warningLevel="4" type="Microsoft.CSharp.CSharpCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<providerOption name="CompilerVersion" value="v3.5"/>
<providerOption name="WarnAsError" value="false"/>
</compiler>
</compilers>
</system.codedom>

 

 

<!-- The system.webServer section is required for running ASP.NET AJAX under Internet Information Services 7.0. It is not necessary for previous version of IIS.-->

<system.webServer>
<validation validateIntegratedModeConfiguration="false"/>
<modules>
<remove name="ScriptModule" />
<add name="ScriptModule" preCondition="managedHandler" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
</modules>

<handlers>
<remove name="WebServiceHandlerFactory-Integrated"/>
<remove name="ScriptHandlerFactory" />
<remove name="ScriptHandlerFactoryAppServices" />
<remove name="ScriptResource" />
<add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode"
type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add name="ScriptHandlerFactoryAppServices" verb="*" path="*_AppService.axd" preCondition="integratedMode"
type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add name="ScriptResource" preCondition="integratedMode" verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
</handlers>
</system.webServer>

<runtime>

<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.Extensions" publicKeyToken="31bf3856ad364e35"/>
<bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Extensions.Design" publicKeyToken="31bf3856ad364e35"/>
<bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0"/>
</dependentAssembly>
</assemblyBinding>
</runtime>

 

</configuration>

-------------------------------------------------------------
The only thing I needed to add over and above was two lines to the web.config on top of the silverlight web app web config bits.

      <SafeControl Assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" Namespace="System.Web.UI" TypeName="*" Safe="True" />
      <SafeControl Assembly="System.Web.Silverlight, Version=2.0.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" Namespace="System.Web.UI.SilverlightControls" TypeName="*" Safe="True" />

I have no idea if this will be of help but I hope it is as I banged my head of a wall for days on this sticking the xap file everywhere under the sun and this eventually fixed it for me.

I have included the web.config here for example purposes only, my advice would be to build your silverlight app and just copy the contents of the web.config from it.

**Note I have left out the bit for IIS7 as I am on Windows 2003 R2 so running IIS 6. If you are running on IIS7 you would need to add this too.

G