Tuesday, November 18, 2008

Integration of Silverlight 2.0 with WSS 3.0 Webparts

First go to the website http://silverlight.net/GetStarted/ and prepare your development environment. My Virtual PC has Windows 2003 SP2 installed. To get started with building Silverlight 2.0 applications:
1. Install Silverlight Tools for Visual Studio 2008 SP1
2. Install Microsoft Expression Blend 2 and then install Microsoft Expression Blend 2 Service Pack 1 (if you subscribe to MSDN you should be able to download Expression Blend 2 and install it on your PC for develpment)
3. Install Deep Zoom Composer
4. Download Silverlight Toolkit
Once your development environment is setup, you should now be able to create Webparts. There are several tutorials and articles for creating a Sharepoint webparts. Once the web part is created and deployed to your website you should be able to drag and drop the webpart into your webpart page.
Now, when you navigate to the page, you may receive a JavaScript error or the silverlight app may not be rendered.
I got the silverlight app to work by doing the following:

1. Add the following MIME types to your website



2. Modify the web.config to include the following:

Add the following to <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>


Add the following to the <httpHandlers>
section:

<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" />

Add the following to the <httpModules>
section:

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

Add the following to the <assemblyBinding>:
<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>

The above modifications should fix the issue and render the webpart.



No comments:

Post a Comment