in

WPF Design and Development

IdentityMine Team Blogs

David Kelley

A day in the life of a humble software architect... doing C#, WPF, Silverlight, Legos, Fuzzy Logic AI and/or whatever is the latest and greatest or more importantly the coolest techo mumbo jumbo...

Silverlight 1.1 As A Sharepoint Web Part

Recently I did a project where I had to embed a Silverlight web part into sharepoint.  You would think this is easy if you haven't done web parts before.  At least thats what I thought.  Granted I have done web parts but it always surprises how much jumping around I had todo.  I found what worked best for me was to create the 1.1 project as a silverlight based server control in a web site that ran all the bits and then to install that in the same domain as the sharepoint server.  At first I tried to make the web part duplicate what the server control did but for some reason Sharepoint would make it render is such a way that the silverlight ended up hidden...  I tried a few things but decided to use an iframe.  This way the web part only outputs a iframe pointed at the controls default page that loads the silverlight interface.  Works like a charm too.  :)  That sounds good but the steps ended up being something like this: 

Silverlight Site Configuration

1.       Copy the Silverlight Website folder to Server Location.

2.       Open IIS Manager (Start-> All Programs -> Administrative Tools -> Internet Information Services (IIS) Manager)

3.       Open Server Node (local Computer)

4.       Open ‘Web Sites’ node.

5.       Open Default running web site node

6.       Right Click web site node and select New -> Virtual Directory

7.       When the Virtual Directory Creation Wizard comes up click next

8.       Enter the correct Alias ‘[some name]’

9.       Click ‘Next’

10.   Click ‘Browse’ and find the physical location of the site directory by drilling down in the ‘Browse For Folder’ and then select ‘OK’

11.   Click ‘Next’

12.   Select ‘Run Scripts’ check box

13.   Click ‘Next’

14.   Click ‘Finish’

Web Part Configuration

1.       Make sure the wep part project is compiled.

2.       Copy the project to the Sharepoint server.

3.       Copy the WebPart.dll to the bin directory under the wwwroot.

4.       From the VS command prompt navigate to the bin directory under wwwroot.

5.       gacutil the dll which should look something like this: gacutil –i WebPart.dll

6.       from this same location in the VS command prompt use the command: sn –T WebPart.dll to find the strong name key.  For example: 7dd6db7c5d0189b7

7.       Find the Sharepoint Web.config by opening up the IIS Manager and selecting the core site and then right click on the web.config and file the file location.

8.       Add a ‘safecontrol’ node to the safecontrols section like this:

<SafeControl

   Assembly="WebPart, Version=1.0.0.0, Culture=neutral,

      PublicKeyToken=7dd6db7c2d0088b7"

   Namespace="[some name space]"

   TypeName="*"

   Safe="True"

/>

9.       Make sure the dwp file has a valid public token.

10.   Go to the Sharepoint home page.

11.   Click Site Actions and select ‘Show Page Editing Toolbar’

12.   Click Page button in the toolbar. 

13.   Select ‘Add Web Parts’ -> Import

14.   Click Browse and find the dwp file in the project.

15.   Click ‘Upload’

16.   Select ‘Add to: Top Zone’

17.   Click ‘Import’

18.   Close the import right hand bar

19.   Select publish from the toolbar

So I'm not saying this is the right method or the best way todo it but it worked for me in my case...  abit of a hack but well its Sharepoint :) 

Comments

No Comments

About david.kelley

David for the past 10 years has focused on distributed application design and emerging Microsoft technologies on the web. Having helped design and build some of the largest systems for companies like Microsoft, Onyx Software, Saltmine, Giordanous Group and more and of course our favorite company Identitymine, he has been on the leading edge of applying the latest tech to real world business problems. David’s technology breadth includes everything from SQL Server to Windows/WCF and Silverlight. David’s accomplishments also include developing new technologies such as self editing XML files and related XML technologies to fuzzy logic systems and advanced web user interface design.
© 2007 IdentityMine, Inc.
Powered by Community Server (Commercial Edition), by Telligent Systems