<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:pingback="http://madskills.com/public/xml/rss/module/pingback/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0">
  <channel>
    <title>Rich Finn - Development</title>
    <link>http://blog.richfinn.net/blog/</link>
    <description>sharepointer</description>
    <language>en-us</language>
    <copyright>Rich Finn</copyright>
    <lastBuildDate>Wed, 26 May 2010 22:31:46 GMT</lastBuildDate>
    <generator>newtelligence dasBlog 2.3.9074.18820</generator>
    <managingEditor>blog.richfinn.net@gmail.com</managingEditor>
    <webMaster>blog.richfinn.net@gmail.com</webMaster>
    <item>
      <trackback:ping>http://blog.richfinn.net/blog/Trackback.aspx?guid=1304471a-f39e-47ec-83f7-4b8d6bb2823b</trackback:ping>
      <pingback:server>http://blog.richfinn.net/blog/pingback.aspx</pingback:server>
      <pingback:target>http://blog.richfinn.net/blog/PermaLink,guid,1304471a-f39e-47ec-83f7-4b8d6bb2823b.aspx</pingback:target>
      <dc:creator>Your DisplayName here!</dc:creator>
      <wfw:comment>http://blog.richfinn.net/blog/CommentView,guid,1304471a-f39e-47ec-83f7-4b8d6bb2823b.aspx</wfw:comment>
      <wfw:commentRss>http://blog.richfinn.net/blog/SyndicationService.asmx/GetEntryCommentsRss?guid=1304471a-f39e-47ec-83f7-4b8d6bb2823b</wfw:commentRss>
      <slash:comments>2</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
When deploying a SharePoint farm solution from Visual Studio 2010 today using the
Deploy command in the right-click context menu on the project node: 
<br /><a href="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/ErroroccurredindeploymentstepRecycleIIS_E866/image_2.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/ErroroccurredindeploymentstepRecycleIIS_E866/image_thumb.png" width="467" height="133" /></a></p>
        <p>
I got this error: Error occurred in deployment step 'Recycle IIS Application Pool':
&lt;nativehr&gt;0x80070005&lt;/nativehr&gt;&lt;nativestack&gt;&lt;/nativestack&gt;Access
denied.
</p>
        <p>
Turns out I wasn’t a site collection admin. Seems easy enough, but my local dev environment
is a domain controller, and I hadn’t given the account I was logged onto the machine
with access to the site.
</p>
        <img width="0" height="0" src="http://blog.richfinn.net/blog/aggbug.ashx?id=1304471a-f39e-47ec-83f7-4b8d6bb2823b" />
      </body>
      <title>Error occurred in deployment step 'Recycle IIS Application Pool': &lt;nativehr&gt;0x80070005&lt;/nativehr&gt;&lt;nativestack&gt;&lt;/nativestack&gt;Access denied.</title>
      <guid isPermaLink="false">http://blog.richfinn.net/blog/PermaLink,guid,1304471a-f39e-47ec-83f7-4b8d6bb2823b.aspx</guid>
      <link>http://blog.richfinn.net/blog/2010/05/26/ErrorOccurredInDeploymentStepRecycleIISApplicationPool0x80070005AccessDenied.aspx</link>
      <pubDate>Wed, 26 May 2010 22:31:46 GMT</pubDate>
      <description>&lt;p&gt;
When deploying a SharePoint farm solution from Visual Studio 2010 today using the
Deploy command in the right-click context menu on the project node: 
&lt;br /&gt;
&lt;a href="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/ErroroccurredindeploymentstepRecycleIIS_E866/image_2.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/ErroroccurredindeploymentstepRecycleIIS_E866/image_thumb.png" width="467" height="133" /&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
I got this error: Error occurred in deployment step 'Recycle IIS Application Pool':
&amp;lt;nativehr&amp;gt;0x80070005&amp;lt;/nativehr&amp;gt;&amp;lt;nativestack&amp;gt;&amp;lt;/nativestack&amp;gt;Access
denied.
&lt;/p&gt;
&lt;p&gt;
Turns out I wasn’t a site collection admin. Seems easy enough, but my local dev environment
is a domain controller, and I hadn’t given the account I was logged onto the machine
with access to the site.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://blog.richfinn.net/blog/aggbug.ashx?id=1304471a-f39e-47ec-83f7-4b8d6bb2823b" /&gt;</description>
      <comments>http://blog.richfinn.net/blog/CommentView,guid,1304471a-f39e-47ec-83f7-4b8d6bb2823b.aspx</comments>
      <category>Development</category>
      <category>SharePoint 2010</category>
    </item>
    <item>
      <trackback:ping>http://blog.richfinn.net/blog/Trackback.aspx?guid=fcf33971-919a-4086-8f53-8dd9d05d0b41</trackback:ping>
      <pingback:server>http://blog.richfinn.net/blog/pingback.aspx</pingback:server>
      <pingback:target>http://blog.richfinn.net/blog/PermaLink,guid,fcf33971-919a-4086-8f53-8dd9d05d0b41.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://blog.richfinn.net/blog/CommentView,guid,fcf33971-919a-4086-8f53-8dd9d05d0b41.aspx</wfw:comment>
      <wfw:commentRss>http://blog.richfinn.net/blog/SyndicationService.asmx/GetEntryCommentsRss?guid=fcf33971-919a-4086-8f53-8dd9d05d0b41</wfw:commentRss>
      <slash:comments>1</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Creating Features which contain custom Content Types or file provisioning modules
requires developers to write a lot of XML based on the wss.xsd. Content types require
custom column and content type definition files, along with the proper creation of
the content type IDs. File provisioning modules require the creation of module elements
which contain the information that will help properly push the files into the correct
lists when the Feature is activated. 
</p>
        <p>
This XML can be fairly daunting, time consuming, and frankly, not very exciting for
developers who just want to test their code. This holds especially true for developers
who are writing custom Features based on SharePoint's Publishing Feature, and this
is why I created <a href="http://www.codeplex.com/SPSource" target="_blank">SPSource</a>.
</p>
        <p>
SPSource helps by alleviating the need for developers to write these files by allowing
them to use the SharePoint UI and SharePoint Designer (SPD) as the source for the
files defined in the module elements, along with custom content types, and is meant
to be integrated with (and has been tested with) WSP creation tools such as <a href="http://www.codeplex.com/wspbuilder" target="_blank">WSPBuilder</a>, <a href="http://www.codeplex.com/stsdev" target="_blank">STSDev</a>,
and the <a href="http://www.codeplex.com/wspprojecttemplate" target="_blank">WSPProjectTemplate</a> as
either part of the build process, or separately as a CMD file at the root of the project.
By using the UI and SPD, items can be created and tested rapidly, then compiled into
the WSP for deployment using familiar tools.
</p>
        <p>
Executing BEFORE the creation of the WSP, any file that can be created using SharePoint
Designer in a document library, and any site content type created in the SharePoint
UI can be targeted and pulled down into Visual Studio for addition in a pre-existing
Visual Studio WSP project. SPSource will also create the file provisioning modules
and site Content Type/Column definition files, as well as the lines needed in the
ElementManifest section of the Feature.xml file.
</p>
        <p>
Some examples of how SPSource can help:
</p>
        <ul>
          <li>
Completely define a custom Publishing Feature using SPD and the SharePoint UI, creating
the master pages, page layouts, content types, style sheets, and images directly in
the content database. Once at a point where it's ready for deployment, run SPSource
against the project and pull everything into a pre-existing WSP. If changes are needed
in the markup, make them using SPD, and re-run SPSource. The files in the WSP will
be updated and ready for a solution upgrade. 
</li>
        </ul>
        <ul>
          <li>
Implement a class on an ASPX page (code behind) in SPD, and code that class in Visual
Studio, or add custom server controls to the markup in SPD. Push your assembly directly
to the GAC or bin as part of the build process, and the code-to-test time is much
faster, as the markup files are already in the content database. Once everything is
set, run SPSource again the project, and pull everything together into the WSP. 
</li>
        </ul>
        <ul>
          <li>
Add a custom Content Query Web Part (or RSS) .webpart file to the web part gallery,
and change the properties and settings for the new CQWP via the UI and SPD to use
custom XSL files that you add to the Style Library/XSL Style Sheets folder. Create
new ItemStyles, change the Headers, or add new parameters to the Main XSL. The XSL
files can be updated quickly using SPD, and changes can be seen right away. When all
is ready for integration into the WSP, execute SPSource against the new files and
create a new Feature for the new web part in minutes. 
</li>
        </ul>
        <p>
Eventually, I hope to get SPSource working with ListInstances and Workflows, but for
right now, it only works with Content Types and Modules.
</p>
        <p>
Check out this <a href="http://video.msn.com/video.aspx?vid=84c63487-8ad6-4e72-a88e-10f39b92135d" target="_blank">screencast</a> where
I create a custom Publishing Feature, with a new content type and page layout, execute
SPSource on my StsDev Visual Studio project, package it all up in a WSP, and deploy
in less than 15 minutes!
</p>
        <p>
          <a title="SPSource Publishing Feature Demo" href="http://video.msn.com/video.aspx?vid=84c63487-8ad6-4e72-a88e-10f39b92135d" target="_new">
            <img height="84" alt="SPSource Publishing Feature Demo" src="http://img2.catalog.video.msn.com/Image.aspx?uuid=84c63487-8ad6-4e72-a88e-10f39b92135d&amp;w=112&amp;h=84" width="112" border="0" />
            <br />
SPSource Publishing Feature Demo</a>
        </p>
        <p>
Here's a short walk-through example of how SPSource works:
</p>
        <p>
In the 'design' site, create a new Content Type for a Publishing page using the SharePoint
UI, adding some new columns<br /><a href="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/BuildingSolutionsWSPinVisualStudioSayhe_DEB3/image_4.png"><img style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height="447" alt="image" src="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/BuildingSolutionsWSPinVisualStudioSayhe_DEB3/image_thumb_1.png" width="517" border="0" /></a></p>
        <p>
 
</p>
        <p>
In SharePoint Designer, create a new Page Layout based on the Content Type which was
just created<br /><a href="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/BuildingSolutionsWSPinVisualStudioSayhe_DEB3/image_6.png"><img style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height="322" alt="image" src="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/BuildingSolutionsWSPinVisualStudioSayhe_DEB3/image_thumb_2.png" width="450" border="0" /></a></p>
        <p>
          <br />
Still in SharePoint Designer, add the new content field controls, a web part zone,
and some other markup to the new Page Layout, saving it to the 'design' site Master
Page Gallery<br /><a href="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/BuildingSolutionsWSPinVisualStudioSayhe_DEB3/image_8.png"><img style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height="314" alt="image" src="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/BuildingSolutionsWSPinVisualStudioSayhe_DEB3/image_thumb_3.png" width="573" border="0" /></a> <br /><br /><br />
Now, over in a Visual Studio project, which in this example is based on StsDev, create
a new Feature, and create some new Folders in that Feature. The folders aren't important
in this case, they just allow for some organization.  SPSource has been tested
using WSPBuilder, StsDEv, and WspProjectTemplate, but the type of project in Visual
Studio really doesn't matter. It just needs to follow the 12Hive folder structure,
which means SPSource does not work with VSEWSS.<br /><a href="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/BuildingSolutionsWSPinVisualStudioSayhe_DEB3/image_10.png"><img style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height="125" alt="image" src="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/BuildingSolutionsWSPinVisualStudioSayhe_DEB3/image_thumb_4.png" width="220" border="0" /></a></p>
        <p>
In each folder, create a new file with the file extension '.spsource'.  This
file extension is important, as the SPSource utility looks for these files to work
it's magic.  The SPSource files are nothing more than a type of XML file and
are what I call 'reverse manifests' as they are based on the same syntax used to push
things into SharePoint, but in the case of SPSource, are used to get things out of
SharePoint.<br /><a href="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/BuildingSolutionsWSPinVisualStudioSayhe_DEB3/image_14.png"><img style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height="118" alt="image" src="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/BuildingSolutionsWSPinVisualStudioSayhe_DEB3/image_thumb_6.png" width="253" border="0" /></a></p>
        <p>
The SPSource file for the Content Type is just like a Content Type definition file,
and is even based on the same schema. All we need is the name of the custom Content
Type we want to have included in the WSP<br /><a href="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/BuildingSolutionsWSPinVisualStudioSayhe_DEB3/image_16.png"><img style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height="121" alt="image" src="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/BuildingSolutionsWSPinVisualStudioSayhe_DEB3/image_thumb_7.png" width="471" border="0" /></a></p>
        <p>
The SPSource file for the custom Page Layout is also just like a provisioning module
file used to put files into SharePoint. We just need to tell it the source list URL,
and the file to include in the WSP<br /><a href="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/BuildingSolutionsWSPinVisualStudioSayhe_DEB3/image_18.png"><img style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height="137" alt="image" src="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/BuildingSolutionsWSPinVisualStudioSayhe_DEB3/image_thumb_8.png" width="466" border="0" /></a></p>
        <p>
At the root of the Visual Studio project, I've got a CMD file that contains the information
needed to execute SPSource<br /><a href="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/BuildingSolutionsWSPinVisualStudioSayhe_DEB3/image_20.png"><img style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height="101" alt="image" src="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/BuildingSolutionsWSPinVisualStudioSayhe_DEB3/image_thumb_9.png" width="150" border="0" /></a><br /><br />
Source of CMD file<br /><a href="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/BuildingSolutionsWSPinVisualStudioSayhe_DEB3/image_22.png"><img style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height="145" alt="image" src="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/BuildingSolutionsWSPinVisualStudioSayhe_DEB3/image_thumb_10.png" width="651" border="0" /></a><br /></p>
        <p>
After SPSource is executed, there will be some new files in your Visual Studio project.<br /><a href="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/BuildingSolutionsWSPinVisualStudioSayhe_DEB3/image_24.png"><img style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height="219" alt="image" src="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/BuildingSolutionsWSPinVisualStudioSayhe_DEB3/image_thumb_11.png" width="316" border="0" /></a></p>
        <p>
In the ContentType folder, there are now files for both the Content Type definition,
as well as the column definitions.<br />
Content Type definition:<br /><a href="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/BuildingSolutionsWSPinVisualStudioSayhe_DEB3/image_26.png"><img style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height="155" alt="image" src="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/BuildingSolutionsWSPinVisualStudioSayhe_DEB3/image_thumb_12.png" width="696" border="0" /></a><br />
Column definition:<br /><a href="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/BuildingSolutionsWSPinVisualStudioSayhe_DEB3/image_28.png"><img style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height="117" alt="image" src="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/BuildingSolutionsWSPinVisualStudioSayhe_DEB3/image_thumb_13.png" width="706" border="0" /></a> <br /></p>
        <p>
The ASPX page in the PageLayouts folder is the same as what we added in SharePoint
designer<br /><a href="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/BuildingSolutionsWSPinVisualStudioSayhe_DEB3/image_30.png"><img style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height="283" alt="image" src="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/BuildingSolutionsWSPinVisualStudioSayhe_DEB3/image_thumb_14.png" width="600" border="0" /></a></p>
        <p>
The pagelayouts.Provisioner.xml file is the provisioning module file needed to put
the custom Page Layout in to the correct location when the Feature is activated<br /><a href="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/BuildingSolutionsWSPinVisualStudioSayhe_DEB3/image_32.png"><img style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height="158" alt="image" src="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/BuildingSolutionsWSPinVisualStudioSayhe_DEB3/image_thumb_15.png" width="707" border="0" /></a></p>
        <p>
The two *.ElementManifest.xml files are there so you have the lines needed to add
to the Feature.xml file in the ElementManfiests section.  These lines are not
automatically added to the Feature.xml as to provide greater flexibility by you to
distinguish what gets included in the Feature.<br /><a href="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/BuildingSolutionsWSPinVisualStudioSayhe_DEB3/image_34.png"><img style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height="132" alt="image" src="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/BuildingSolutionsWSPinVisualStudioSayhe_DEB3/image_thumb_16.png" width="706" border="0" /></a></p>
        <p>
After I add the lines to the Feature file:<br /><a href="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/BuildingSolutionsWSPinVisualStudioSayhe_DEB3/image_36.png"><img style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height="251" alt="image" src="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/BuildingSolutionsWSPinVisualStudioSayhe_DEB3/image_thumb_17.png" width="619" border="0" /></a> 
</p>
        <p>
Now I can build my project to compile the WSP and deploy it to the 'development' site. 
SPSource can also be integrated with the MSBuild process to allow for updates to the
files added by SPSource before the WSP is compiled.  This allows the WSP to be
upgraded using items changed in the UI and SharePoint Designer.
</p>
        <p>
After the solution is built and deployed, the Feature can be activated, and the pages
will be added to the Master Page Gallery<br /><a href="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/BuildingSolutionsWSPinVisualStudioSayhe_DEB3/image_38.png"><img style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height="43" alt="image" src="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/BuildingSolutionsWSPinVisualStudioSayhe_DEB3/image_thumb_18.png" width="601" border="0" /></a> <br /><br />
Master Page Gallery<br /><a href="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/BuildingSolutionsWSPinVisualStudioSayhe_DEB3/image_40.png"><img style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height="25" alt="image" src="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/BuildingSolutionsWSPinVisualStudioSayhe_DEB3/image_thumb_19.png" width="744" border="0" /></a><br /><br />
When I create a new page, the new Page Layout is available in the list, as expected<br /><a href="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/BuildingSolutionsWSPinVisualStudioSayhe_DEB3/image_42.png"><img style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height="138" alt="image" src="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/BuildingSolutionsWSPinVisualStudioSayhe_DEB3/image_thumb_20.png" width="713" border="0" /></a> <br /><br />
and, the page looks the way it should<br /><a href="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/BuildingSolutionsWSPinVisualStudioSayhe_DEB3/image_44.png"><img style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height="278" alt="image" src="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/BuildingSolutionsWSPinVisualStudioSayhe_DEB3/image_thumb_21.png" width="393" border="0" /></a></p>
        <p>
Give <a href="http://www.codeplex.com/SPSource" target="_blank">SPSource</a> a try,
and see how much more efficient your Visual Studio WSP creation process can be!
</p>
        <img width="0" height="0" src="http://blog.richfinn.net/blog/aggbug.ashx?id=fcf33971-919a-4086-8f53-8dd9d05d0b41" />
      </body>
      <title>Building Solutions (WSP) in Visual Studio? Say hello to SPSource...</title>
      <guid isPermaLink="false">http://blog.richfinn.net/blog/PermaLink,guid,fcf33971-919a-4086-8f53-8dd9d05d0b41.aspx</guid>
      <link>http://blog.richfinn.net/blog/2008/08/13/BuildingSolutionsWSPInVisualStudioSayHelloToSPSource.aspx</link>
      <pubDate>Wed, 13 Aug 2008 23:13:21 GMT</pubDate>
      <description>&lt;p&gt;
Creating Features which contain custom Content Types or file provisioning modules
requires developers to write a lot of XML based on the wss.xsd. Content types require
custom column and content type definition files, along with the proper creation of
the content type IDs. File provisioning modules require the creation of module elements
which contain the information that will help properly push the files into the correct
lists when the Feature is activated. 
&lt;/p&gt;
&lt;p&gt;
This XML can be fairly daunting, time consuming, and frankly, not very exciting for
developers who just want to test their code. This holds especially true for developers
who are writing custom Features based on SharePoint's Publishing Feature, and this
is why I created &lt;a href="http://www.codeplex.com/SPSource" target=_blank&gt;SPSource&lt;/a&gt;.
&lt;/p&gt;
&lt;p&gt;
SPSource helps by alleviating the need for developers to write these files by allowing
them to use the SharePoint UI and SharePoint Designer (SPD) as the source for the
files defined in the module elements, along with custom content types, and is meant
to be integrated with (and has been tested with) WSP creation tools such as &lt;a href="http://www.codeplex.com/wspbuilder" target=_blank&gt;WSPBuilder&lt;/a&gt;, &lt;a href="http://www.codeplex.com/stsdev" target=_blank&gt;STSDev&lt;/a&gt;,
and the &lt;a href="http://www.codeplex.com/wspprojecttemplate" target=_blank&gt;WSPProjectTemplate&lt;/a&gt; as
either part of the build process, or separately as a CMD file at the root of the project.
By using the UI and SPD, items can be created and tested rapidly, then compiled into
the WSP for deployment using familiar tools.
&lt;/p&gt;
&lt;p&gt;
Executing BEFORE the creation of the WSP, any file that can be created using SharePoint
Designer in a document library, and any site content type created in the SharePoint
UI can be targeted and pulled down into Visual Studio for addition in a pre-existing
Visual Studio WSP project. SPSource will also create the file provisioning modules
and site Content Type/Column definition files, as well as the lines needed in the
ElementManifest section of the Feature.xml file.
&lt;/p&gt;
&lt;p&gt;
Some examples of how SPSource can help:
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
Completely define a custom Publishing Feature using SPD and the SharePoint UI, creating
the master pages, page layouts, content types, style sheets, and images directly in
the content database. Once at a point where it's ready for deployment, run SPSource
against the project and pull everything into a pre-existing WSP. If changes are needed
in the markup, make them using SPD, and re-run SPSource. The files in the WSP will
be updated and ready for a solution upgrade. 
&lt;/li&gt;
&lt;/ul&gt;
&lt;ul&gt;
&lt;li&gt;
Implement a class on an ASPX page (code behind) in SPD, and code that class in Visual
Studio, or add custom server controls to the markup in SPD. Push your assembly directly
to the GAC or bin as part of the build process, and the code-to-test time is much
faster, as the markup files are already in the content database. Once everything is
set, run SPSource again the project, and pull everything together into the WSP. 
&lt;/li&gt;
&lt;/ul&gt;
&lt;ul&gt;
&lt;li&gt;
Add a custom Content Query Web Part (or RSS) .webpart file to the web part gallery,
and change the properties and settings for the new CQWP via the UI and SPD to use
custom XSL files that you add to the Style Library/XSL Style Sheets folder. Create
new ItemStyles, change the Headers, or add new parameters to the Main XSL. The XSL
files can be updated quickly using SPD, and changes can be seen right away. When all
is ready for integration into the WSP, execute SPSource against the new files and
create a new Feature for the new web part in minutes. 
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
Eventually, I hope to get SPSource working with ListInstances and Workflows, but for
right now, it only works with Content Types and Modules.
&lt;/p&gt;
&lt;p&gt;
Check out this &lt;a href="http://video.msn.com/video.aspx?vid=84c63487-8ad6-4e72-a88e-10f39b92135d" target=_blank&gt;screencast&lt;/a&gt; where
I create a custom Publishing Feature, with a new content type and page layout, execute
SPSource on my StsDev Visual Studio project, package it all up in a WSP, and deploy
in less than 15 minutes!
&lt;/p&gt;
&lt;p&gt;
&lt;a title="SPSource Publishing Feature Demo" href="http://video.msn.com/video.aspx?vid=84c63487-8ad6-4e72-a88e-10f39b92135d" target=_new&gt;&lt;img height=84 alt="SPSource Publishing Feature Demo" src="http://img2.catalog.video.msn.com/Image.aspx?uuid=84c63487-8ad6-4e72-a88e-10f39b92135d&amp;amp;w=112&amp;amp;h=84" width=112 border=0&gt;
&lt;br&gt;
SPSource Publishing Feature Demo&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
Here's a short walk-through example of how SPSource works:
&lt;/p&gt;
&lt;p&gt;
In the 'design' site, create a new Content Type for a Publishing page using the SharePoint
UI, adding some new columns&lt;br&gt;
&lt;a href="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/BuildingSolutionsWSPinVisualStudioSayhe_DEB3/image_4.png"&gt;&lt;img style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height=447 alt=image src="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/BuildingSolutionsWSPinVisualStudioSayhe_DEB3/image_thumb_1.png" width=517 border=0&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
In SharePoint Designer, create a new Page Layout based on the Content Type which was
just created&lt;br&gt;
&lt;a href="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/BuildingSolutionsWSPinVisualStudioSayhe_DEB3/image_6.png"&gt;&lt;img style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height=322 alt=image src="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/BuildingSolutionsWSPinVisualStudioSayhe_DEB3/image_thumb_2.png" width=450 border=0&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
&lt;br&gt;
Still in SharePoint Designer, add the new content field controls, a web part zone,
and some other markup to the new Page Layout, saving it to the 'design' site Master
Page Gallery&lt;br&gt;
&lt;a href="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/BuildingSolutionsWSPinVisualStudioSayhe_DEB3/image_8.png"&gt;&lt;img style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height=314 alt=image src="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/BuildingSolutionsWSPinVisualStudioSayhe_DEB3/image_thumb_3.png" width=573 border=0&gt;&lt;/a&gt;&amp;nbsp;&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
Now, over in a Visual Studio project, which in this example is based on StsDev, create
a new Feature, and create some new Folders in that Feature. The folders aren't important
in this case, they just allow for some organization.&amp;nbsp; SPSource has been tested
using WSPBuilder, StsDEv, and WspProjectTemplate, but the type of project in Visual
Studio really doesn't matter. It just needs to follow the 12Hive folder structure,
which means SPSource does not work with VSEWSS.&lt;br&gt;
&lt;a href="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/BuildingSolutionsWSPinVisualStudioSayhe_DEB3/image_10.png"&gt;&lt;img style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height=125 alt=image src="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/BuildingSolutionsWSPinVisualStudioSayhe_DEB3/image_thumb_4.png" width=220 border=0&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
In each folder, create a new file with the file extension '.spsource'.&amp;nbsp; This
file extension is important, as the SPSource utility looks for these files to work
it's magic.&amp;nbsp; The SPSource files are nothing more than a type of XML file and
are what I call 'reverse manifests' as they are based on the same syntax used to push
things into SharePoint, but in the case of SPSource, are used to get things out of
SharePoint.&lt;br&gt;
&lt;a href="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/BuildingSolutionsWSPinVisualStudioSayhe_DEB3/image_14.png"&gt;&lt;img style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height=118 alt=image src="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/BuildingSolutionsWSPinVisualStudioSayhe_DEB3/image_thumb_6.png" width=253 border=0&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
The SPSource file for the Content Type is just like a Content Type definition file,
and is even based on the same schema. All we need is the name of the custom Content
Type we want to have included in the WSP&lt;br&gt;
&lt;a href="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/BuildingSolutionsWSPinVisualStudioSayhe_DEB3/image_16.png"&gt;&lt;img style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height=121 alt=image src="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/BuildingSolutionsWSPinVisualStudioSayhe_DEB3/image_thumb_7.png" width=471 border=0&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
The SPSource file for the custom Page Layout is also just like a provisioning module
file used to put files into SharePoint. We just need to tell it the source list URL,
and the file to include in the WSP&lt;br&gt;
&lt;a href="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/BuildingSolutionsWSPinVisualStudioSayhe_DEB3/image_18.png"&gt;&lt;img style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height=137 alt=image src="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/BuildingSolutionsWSPinVisualStudioSayhe_DEB3/image_thumb_8.png" width=466 border=0&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
At the root of the Visual Studio project, I've got a CMD file that contains the information
needed to execute SPSource&lt;br&gt;
&lt;a href="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/BuildingSolutionsWSPinVisualStudioSayhe_DEB3/image_20.png"&gt;&lt;img style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height=101 alt=image src="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/BuildingSolutionsWSPinVisualStudioSayhe_DEB3/image_thumb_9.png" width=150 border=0&gt;&lt;/a&gt; 
&lt;br&gt;
&lt;br&gt;
Source of CMD file&lt;br&gt;
&lt;a href="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/BuildingSolutionsWSPinVisualStudioSayhe_DEB3/image_22.png"&gt;&lt;img style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height=145 alt=image src="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/BuildingSolutionsWSPinVisualStudioSayhe_DEB3/image_thumb_10.png" width=651 border=0&gt;&lt;/a&gt; 
&lt;br&gt;
&lt;/p&gt;
&lt;p&gt;
After SPSource is executed, there will be some new files in your Visual Studio project.&lt;br&gt;
&lt;a href="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/BuildingSolutionsWSPinVisualStudioSayhe_DEB3/image_24.png"&gt;&lt;img style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height=219 alt=image src="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/BuildingSolutionsWSPinVisualStudioSayhe_DEB3/image_thumb_11.png" width=316 border=0&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
In the ContentType folder, there are now files for both the Content Type definition,
as well as the column definitions.&lt;br&gt;
Content Type definition:&lt;br&gt;
&lt;a href="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/BuildingSolutionsWSPinVisualStudioSayhe_DEB3/image_26.png"&gt;&lt;img style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height=155 alt=image src="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/BuildingSolutionsWSPinVisualStudioSayhe_DEB3/image_thumb_12.png" width=696 border=0&gt;&lt;/a&gt; 
&lt;br&gt;
Column definition:&lt;br&gt;
&lt;a href="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/BuildingSolutionsWSPinVisualStudioSayhe_DEB3/image_28.png"&gt;&lt;img style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height=117 alt=image src="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/BuildingSolutionsWSPinVisualStudioSayhe_DEB3/image_thumb_13.png" width=706 border=0&gt;&lt;/a&gt;&amp;nbsp;&lt;br&gt;
&lt;/p&gt;
&lt;p&gt;
The ASPX page in the PageLayouts folder is the same as what we added in SharePoint
designer&lt;br&gt;
&lt;a href="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/BuildingSolutionsWSPinVisualStudioSayhe_DEB3/image_30.png"&gt;&lt;img style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height=283 alt=image src="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/BuildingSolutionsWSPinVisualStudioSayhe_DEB3/image_thumb_14.png" width=600 border=0&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
The pagelayouts.Provisioner.xml file is the provisioning module file needed to put
the custom Page Layout in to the correct location when the Feature is activated&lt;br&gt;
&lt;a href="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/BuildingSolutionsWSPinVisualStudioSayhe_DEB3/image_32.png"&gt;&lt;img style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height=158 alt=image src="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/BuildingSolutionsWSPinVisualStudioSayhe_DEB3/image_thumb_15.png" width=707 border=0&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
The two *.ElementManifest.xml files are there so you have the lines needed to add
to the Feature.xml file in the ElementManfiests section.&amp;nbsp; These lines are not
automatically added to the Feature.xml as to provide greater flexibility by you to
distinguish what gets included in the Feature.&lt;br&gt;
&lt;a href="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/BuildingSolutionsWSPinVisualStudioSayhe_DEB3/image_34.png"&gt;&lt;img style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height=132 alt=image src="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/BuildingSolutionsWSPinVisualStudioSayhe_DEB3/image_thumb_16.png" width=706 border=0&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
After I add the lines to the Feature file:&lt;br&gt;
&lt;a href="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/BuildingSolutionsWSPinVisualStudioSayhe_DEB3/image_36.png"&gt;&lt;img style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height=251 alt=image src="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/BuildingSolutionsWSPinVisualStudioSayhe_DEB3/image_thumb_17.png" width=619 border=0&gt;&lt;/a&gt;&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
Now I can build my project to compile the WSP and deploy it to the 'development' site.&amp;nbsp;
SPSource can also be integrated with the MSBuild process to allow for updates to the
files added by SPSource before the WSP is compiled.&amp;nbsp; This allows the WSP to be
upgraded using items changed in the UI and SharePoint Designer.
&lt;/p&gt;
&lt;p&gt;
After the solution is built and deployed, the Feature can be activated, and the pages
will be added to the Master Page Gallery&lt;br&gt;
&lt;a href="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/BuildingSolutionsWSPinVisualStudioSayhe_DEB3/image_38.png"&gt;&lt;img style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height=43 alt=image src="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/BuildingSolutionsWSPinVisualStudioSayhe_DEB3/image_thumb_18.png" width=601 border=0&gt;&lt;/a&gt;&amp;nbsp;&lt;br&gt;
&lt;br&gt;
Master Page Gallery&lt;br&gt;
&lt;a href="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/BuildingSolutionsWSPinVisualStudioSayhe_DEB3/image_40.png"&gt;&lt;img style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height=25 alt=image src="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/BuildingSolutionsWSPinVisualStudioSayhe_DEB3/image_thumb_19.png" width=744 border=0&gt;&lt;/a&gt; 
&lt;br&gt;
&lt;br&gt;
When I create a new page, the new Page Layout is available in the list, as expected&lt;br&gt;
&lt;a href="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/BuildingSolutionsWSPinVisualStudioSayhe_DEB3/image_42.png"&gt;&lt;img style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height=138 alt=image src="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/BuildingSolutionsWSPinVisualStudioSayhe_DEB3/image_thumb_20.png" width=713 border=0&gt;&lt;/a&gt;&amp;nbsp;&lt;br&gt;
&lt;br&gt;
and, the page looks the way it should&lt;br&gt;
&lt;a href="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/BuildingSolutionsWSPinVisualStudioSayhe_DEB3/image_44.png"&gt;&lt;img style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height=278 alt=image src="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/BuildingSolutionsWSPinVisualStudioSayhe_DEB3/image_thumb_21.png" width=393 border=0&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
Give &lt;a href="http://www.codeplex.com/SPSource" target=_blank&gt;SPSource&lt;/a&gt; a try,
and see how much more efficient your Visual Studio WSP creation process can be!
&lt;/p&gt;
&lt;img width="0" height="0" src="http://blog.richfinn.net/blog/aggbug.ashx?id=fcf33971-919a-4086-8f53-8dd9d05d0b41" /&gt;</description>
      <comments>http://blog.richfinn.net/blog/CommentView,guid,fcf33971-919a-4086-8f53-8dd9d05d0b41.aspx</comments>
      <category>Development</category>
      <category>Microsoft Office SharePoint Server</category>
      <category>SPSource</category>
      <category>WSP Development</category>
      <category>WSS</category>
    </item>
    <item>
      <trackback:ping>http://blog.richfinn.net/blog/Trackback.aspx?guid=4d7b3f9d-a9a5-4bd4-b9b0-106f2f3b6468</trackback:ping>
      <pingback:server>http://blog.richfinn.net/blog/pingback.aspx</pingback:server>
      <pingback:target>http://blog.richfinn.net/blog/PermaLink,guid,4d7b3f9d-a9a5-4bd4-b9b0-106f2f3b6468.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://blog.richfinn.net/blog/CommentView,guid,4d7b3f9d-a9a5-4bd4-b9b0-106f2f3b6468.aspx</wfw:comment>
      <wfw:commentRss>http://blog.richfinn.net/blog/SyndicationService.asmx/GetEntryCommentsRss?guid=4d7b3f9d-a9a5-4bd4-b9b0-106f2f3b6468</wfw:commentRss>
      <slash:comments>2</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
We've been working on this one for a while, and it's been driving us nuts...
</p>
        <p>
In the current project we're working on, we haven't been able to add any new web parts
to pages, nor have we been able to edit the properties on the existing ones. 
When we do, we've been seeing the three following errors:
</p>
        <p>
- <font color="#ff0000">Cannot save the property settings for this Web Part. Exception
occurred. (Exception from HRESULT: 0x80020009 (DISP_E_EXCEPTION))<br /></font>- <font color="#ff0000">Unable to add selected web part(s). Exception occurred.
(Exception from HRESULT: 0x80020009 (DISP_E_EXCEPTION))</font><br />
- <font color="#ff0000">Unable to add selected web part(s). List View Web Part could
not be added, list may be hidden.</font></p>
        <p>
Even stranger was that it was only occurring in the root web of the current site collection.
</p>
        <p>
In researching the 0x80020008 error when related to web parts, the few people that
have found anything have said that it could be caused by disposal of the SPContext.Current.Site
or SPContect.Current.Web objects.  We looked all over our code and didn't find
that we were doing that anywhere.
</p>
        <p>
We switched the master page back to the default.master, and we could add and edit
web parts without any issues, so we then started whittling down the server controls
on the custom master page until we found three custom server controls that were present
when the web part errors occur.  Taking a closer look, these three controls all
had the following lines in common.
</p>
        <div style="BORDER-RIGHT: gray 1px solid; PADDING-RIGHT: 4px; BORDER-TOP: gray 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 8pt; PADDING-BOTTOM: 4px; MARGIN: 20px 0px 10px; OVERFLOW: auto; BORDER-LEFT: gray 1px solid; WIDTH: 97.5%; CURSOR: text; MAX-HEIGHT: 200px; LINE-HEIGHT: 12pt; PADDING-TOP: 4px; BORDER-BOTTOM: gray 1px solid; FONT-FAMILY: consolas, 'Courier New', courier, monospace; HEIGHT: 91px; BACKGROUND-COLOR: #f4f4f4">
          <pre style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none">
            <span style="COLOR: #0000ff">using</span> (SPWeb
rootWeb = SPContext.Current.Site.RootWeb) { <span style="COLOR: #008000">//code</span> }</pre>
        </div>
        <p>
Commenting out of the code caused the errors to go away.  What's going on here?  
</p>
        <p>
Turns out that there's something that the <a href="http://msdn.microsoft.com/en-us/library/aa973248.aspx" target="_blank">Best
Practices: Using Disposable Windows SharePoint Services Objects</a> post and Roger
Lamb's <a href="http://blogs.msdn.com/rogerla/archive/2008/02/12/sharepoint-2007-and-wss-3-0-dispose-patterns-by-example.aspx" target="_blank">SharePoint
2007 and WSS 3.0 Dispose Patterns by Example</a> should point out a little clearer. 
If you look at the bottom of Roger's post, there's a comment by <a href="http://stephenkaye.blogspot.com/" target="_blank">Stephen
Kaye</a> where he hits the nail on the head:
</p>
        <blockquote>
          <p>
            <em>If your current context’s web is the root web of you current context’s site then
the RootWeb property of the site will reference the same object return by SPControl.GetContextWeb
and SPContext.Current.Web and should therefore not be disposed.</em>
          </p>
        </blockquote>
        <p>
So, this means that if you are in the root web of your site collection, and you dispose
of SPContext.Current.Site.RootWeb, you're actually disposing of SPContext.Current.Web. 
Not good.
</p>
        <p>
Here's how we changed the code to ensure that we could use the RootWeb SPWeb object,
but not dispose it if the SPContext.Current.Web is the RootWeb:
</p>
        <div style="BORDER-RIGHT: gray 1px solid; PADDING-RIGHT: 4px; BORDER-TOP: gray 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 8pt; PADDING-BOTTOM: 4px; MARGIN: 20px 0px 10px; OVERFLOW: auto; BORDER-LEFT: gray 1px solid; WIDTH: 97.5%; CURSOR: text; MAX-HEIGHT: 200px; LINE-HEIGHT: 12pt; PADDING-TOP: 4px; BORDER-BOTTOM: gray 1px solid; FONT-FAMILY: consolas, 'Courier New', courier, monospace; HEIGHT: 214px; BACKGROUND-COLOR: #f4f4f4">
          <pre style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none">SPWeb rootWeb = <span style="COLOR: #0000ff">null</span>; <span style="COLOR: #0000ff">if</span> (SPContext.Current.Web.IsRootWeb)
rootWeb = SPContext.Current.Web; <span style="COLOR: #0000ff">else</span> rootWeb
= SPContext.Current.Site.RootWeb; <span style="COLOR: #008000">//code</span><span style="COLOR: #0000ff">if</span> (!SPContext.Current.Web.IsRootWeb)
rootWeb.Dispose();</pre>
        </div>
        <img width="0" height="0" src="http://blog.richfinn.net/blog/aggbug.ashx?id=4d7b3f9d-a9a5-4bd4-b9b0-106f2f3b6468" />
      </body>
      <title>SPContext.Current.Site.RootWeb.Dispose() and the webpart error '(Exception from HRESULT: 0x80020009 (DISP_E_EXCEPTION))'</title>
      <guid isPermaLink="false">http://blog.richfinn.net/blog/PermaLink,guid,4d7b3f9d-a9a5-4bd4-b9b0-106f2f3b6468.aspx</guid>
      <link>http://blog.richfinn.net/blog/2008/07/17/SPContextCurrentSiteRootWebDisposeAndTheWebpartErrorExceptionFromHRESULT0x80020009DISPEEXCEPTION.aspx</link>
      <pubDate>Thu, 17 Jul 2008 00:18:46 GMT</pubDate>
      <description>&lt;p&gt;
We've been working on this one for a while, and it's been driving us nuts...
&lt;/p&gt;
&lt;p&gt;
In the current project we're working on, we haven't been able to add any new web parts
to pages, nor have we been able to edit the properties on the existing ones.&amp;nbsp;
When we do, we've been seeing the three following errors:
&lt;/p&gt;
&lt;p&gt;
- &lt;font color=#ff0000&gt;Cannot save the property settings for this Web Part. Exception
occurred. (Exception from HRESULT: 0x80020009 (DISP_E_EXCEPTION))&lt;br&gt;
&lt;/font&gt;- &lt;font color=#ff0000&gt;Unable to add selected web part(s). Exception occurred.
(Exception from HRESULT: 0x80020009 (DISP_E_EXCEPTION))&lt;/font&gt;
&lt;br&gt;
- &lt;font color=#ff0000&gt;Unable to add selected web part(s). List View Web Part could
not be added, list may be hidden.&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
Even stranger was that it was only occurring in the root web of the current site collection.
&lt;/p&gt;
&lt;p&gt;
In researching the 0x80020008 error when related to web parts, the few people that
have found anything have said that it could be caused by disposal of the SPContext.Current.Site
or SPContect.Current.Web objects.&amp;nbsp; We looked all over our code and didn't find
that we were doing that anywhere.
&lt;/p&gt;
&lt;p&gt;
We switched the master page back to the default.master, and we could add and edit
web parts without any issues, so we then started whittling down the server controls
on the custom master page until we found three custom server controls that were present
when the web part errors occur.&amp;nbsp; Taking a closer look, these three controls all
had the following lines in common.
&lt;/p&gt;
&lt;div style="BORDER-RIGHT: gray 1px solid; PADDING-RIGHT: 4px; BORDER-TOP: gray 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 8pt; PADDING-BOTTOM: 4px; MARGIN: 20px 0px 10px; OVERFLOW: auto; BORDER-LEFT: gray 1px solid; WIDTH: 97.5%; CURSOR: text; MAX-HEIGHT: 200px; LINE-HEIGHT: 12pt; PADDING-TOP: 4px; BORDER-BOTTOM: gray 1px solid; FONT-FAMILY: consolas, 'Courier New', courier, monospace; HEIGHT: 91px; BACKGROUND-COLOR: #f4f4f4"&gt;&lt;pre style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none"&gt;&lt;span style="COLOR: #0000ff"&gt;using&lt;/span&gt; (SPWeb
rootWeb = SPContext.Current.Site.RootWeb) { &lt;span style="COLOR: #008000"&gt;//code&lt;/span&gt; }&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;
Commenting out of the code caused the errors to go away.&amp;nbsp; What's going on here?&amp;nbsp; 
&lt;/p&gt;
&lt;p&gt;
Turns out that there's something that the &lt;a href="http://msdn.microsoft.com/en-us/library/aa973248.aspx" target=_blank&gt;Best
Practices: Using Disposable Windows SharePoint Services Objects&lt;/a&gt; post and Roger
Lamb's &lt;a href="http://blogs.msdn.com/rogerla/archive/2008/02/12/sharepoint-2007-and-wss-3-0-dispose-patterns-by-example.aspx" target=_blank&gt;SharePoint
2007 and WSS 3.0 Dispose Patterns by Example&lt;/a&gt; should point out a little clearer.&amp;nbsp;
If you look at the bottom of Roger's post, there's a comment by &lt;a href="http://stephenkaye.blogspot.com/" target=_blank&gt;Stephen
Kaye&lt;/a&gt; where he hits the nail on the head:
&lt;/p&gt;
&lt;blockquote&gt; 
&lt;p&gt;
&lt;em&gt;If your current context’s web is the root web of you current context’s site then
the RootWeb property of the site will reference the same object return by SPControl.GetContextWeb
and SPContext.Current.Web and should therefore not be disposed.&lt;/em&gt;
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
So, this means that if you are in the root web of your site collection, and you dispose
of SPContext.Current.Site.RootWeb, you're actually disposing of SPContext.Current.Web.&amp;nbsp;
Not good.
&lt;/p&gt;
&lt;p&gt;
Here's how we changed the code to ensure that we could use the RootWeb SPWeb object,
but not dispose it if the SPContext.Current.Web is the RootWeb:
&lt;/p&gt;
&lt;div style="BORDER-RIGHT: gray 1px solid; PADDING-RIGHT: 4px; BORDER-TOP: gray 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 8pt; PADDING-BOTTOM: 4px; MARGIN: 20px 0px 10px; OVERFLOW: auto; BORDER-LEFT: gray 1px solid; WIDTH: 97.5%; CURSOR: text; MAX-HEIGHT: 200px; LINE-HEIGHT: 12pt; PADDING-TOP: 4px; BORDER-BOTTOM: gray 1px solid; FONT-FAMILY: consolas, 'Courier New', courier, monospace; HEIGHT: 214px; BACKGROUND-COLOR: #f4f4f4"&gt;&lt;pre style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none"&gt;SPWeb rootWeb = &lt;span style="COLOR: #0000ff"&gt;null&lt;/span&gt;; &lt;span style="COLOR: #0000ff"&gt;if&lt;/span&gt; (SPContext.Current.Web.IsRootWeb)
rootWeb = SPContext.Current.Web; &lt;span style="COLOR: #0000ff"&gt;else&lt;/span&gt; rootWeb
= SPContext.Current.Site.RootWeb; &lt;span style="COLOR: #008000"&gt;//code&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;if&lt;/span&gt; (!SPContext.Current.Web.IsRootWeb)
rootWeb.Dispose();&lt;/pre&gt;
&lt;/div&gt;
&lt;img width="0" height="0" src="http://blog.richfinn.net/blog/aggbug.ashx?id=4d7b3f9d-a9a5-4bd4-b9b0-106f2f3b6468" /&gt;</description>
      <comments>http://blog.richfinn.net/blog/CommentView,guid,4d7b3f9d-a9a5-4bd4-b9b0-106f2f3b6468.aspx</comments>
      <category>Development</category>
      <category>Microsoft Office SharePoint Server</category>
      <category>WSS</category>
    </item>
    <item>
      <trackback:ping>http://blog.richfinn.net/blog/Trackback.aspx?guid=55cbf57f-6d3d-444e-aa45-6b9335301260</trackback:ping>
      <pingback:server>http://blog.richfinn.net/blog/pingback.aspx</pingback:server>
      <pingback:target>http://blog.richfinn.net/blog/PermaLink,guid,55cbf57f-6d3d-444e-aa45-6b9335301260.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://blog.richfinn.net/blog/CommentView,guid,55cbf57f-6d3d-444e-aa45-6b9335301260.aspx</wfw:comment>
      <wfw:commentRss>http://blog.richfinn.net/blog/SyndicationService.asmx/GetEntryCommentsRss?guid=55cbf57f-6d3d-444e-aa45-6b9335301260</wfw:commentRss>
      <slash:comments>2</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
In our current SharePoint project, we have a custom site definition based on the out-of-box
Publishing Site with Workflow. We found a little problem with this though, because
when the out-of-box Features for Publishing and it's Parallel Approval workflow are
activated, the default SharePoint Approvers group is the only group that is set to
approve a publishing page that has been sent into the workflow. The problem is, we
want to inherit the parent site's workflow settings - otherwise known as the association
data - because our application has 'channels' of content that each has a different
group who can approve the content in their appropriate channel.
</p>
        <p>
The group that can approve publishing pages in each channel is defined in the root
web of the channel by doing nothing more than editing the Parallel Approval workflow
on the Pages list, and then setting the correct group on the People Picker for the
workflow approvers property. Since channel owners can create new sites in their channel
using our custom provisioning process, we don't want them to have to go into the Pages
list workflow settings to set the correct group every time, because as we all know,
people make mistakes. Why not automate this process and set the right approvers group
for the channel owner when the new site is created?
</p>
        <p>
To do this, we created a Feature that we <a href="http://www.sharepointnutsandbolts.com/2007/05/feature-stapling.html" target="_blank">included
in our custom site definition</a>.  When a new site is created and the Feature
is activated, we execute the following code:
</p>
        <div style="BORDER-RIGHT: gray 1px solid; PADDING-RIGHT: 4px; BORDER-TOP: gray 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 8pt; PADDING-BOTTOM: 4px; MARGIN: 20px 0px 10px; OVERFLOW: auto; BORDER-LEFT: gray 1px solid; WIDTH: 97.5%; CURSOR: text; LINE-HEIGHT: 12pt; PADDING-TOP: 4px; BORDER-BOTTOM: gray 1px solid; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BACKGROUND-COLOR: #f4f4f4">
          <pre style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none">
            <p>
              <span style="COLOR: #0000ff">using</span> System; <span style="COLOR: #0000ff">using</span> System.Collections.Generic; <span style="COLOR: #0000ff">using</span> System.Text; <span style="COLOR: #0000ff">using</span> Microsoft.SharePoint; <span style="COLOR: #0000ff">using</span> System.Diagnostics; <span style="COLOR: #0000ff">using</span> Microsoft.SharePoint.Workflow; <span style="COLOR: #0000ff">using</span> System.Xml; <span style="COLOR: #0000ff">using</span> Microsoft.SharePoint.Publishing; <span style="COLOR: #0000ff">namespace</span> Demo
{ <span style="COLOR: #0000ff">public</span><span style="COLOR: #0000ff">class</span> FeatureReceiver
: SPFeatureReceiver { <span style="COLOR: #0000ff">public</span><span style="COLOR: #0000ff">override</span><span style="COLOR: #0000ff">void</span> FeatureActivated(SPFeatureReceiverProperties
properties) { <span style="COLOR: #008000">//get the SPWeb object for the Feature's
scope</span> SPWeb currentWeb = properties.Feature.Parent <span style="COLOR: #0000ff">as</span> SPWeb; <span style="COLOR: #008000">//set
the AllowUnsafeUpdates property to true so we can apply the change to the workflow</span> currentWeb.AllowUnsafeUpdates
= <span style="COLOR: #0000ff">true</span>; <span style="COLOR: #008000">//get the
parent web of the current web - this is where the correct workflow settings are</span> SPWeb
parentWeb = currentWeb.ParentWeb; <span style="COLOR: #008000">//get the Pages list
from the current web using the PublishingWeb object</span> SPList currentWebPublishingList
= PublishingWeb.GetPublishingWeb(currentWeb).PagesList; <span style="COLOR: #008000">//get
the current web Pages list's workflows</span> SPWorkflowAssociationCollection currentWebWorkflows
= currentWebPublishingList.WorkflowAssociations; <span style="COLOR: #008000">//if
the site has workflows, we need to get the parent web's workflow and apply the same
approvers to it</span><span style="COLOR: #0000ff">if</span> (currentWebWorkflows.Count
&gt;= 1) { <span style="COLOR: #008000">//find the parallel approval workflow</span> SPWorkflowAssociation
currentWorkflowAssociation = currentWebWorkflows.GetAssociationByName(<span style="COLOR: #006080">"Parallel
Approval"</span>, currentWeb.Locale); <span style="COLOR: #008000">//empty container
for the parent pages list workflow</span> SPWorkflowAssociation parentWorkflowAssociation
= <span style="COLOR: #0000ff">null</span>; <span style="COLOR: #008000">//get the
parent site's pages list</span> SPList parentPagesList = PublishingWeb.GetPublishingWeb(parentWeb).PagesList; <span style="COLOR: #008000">//if
there's workflows attached, we need to find the Parallel Approval workflow</span><span style="COLOR: #0000ff">if</span> (parentPagesList.WorkflowAssociations.Count
&gt; 0) { parentWorkflowAssociation = parentPagesList.WorkflowAssociations.GetAssociationByName(<span style="COLOR: #006080">"Parallel
Approval"</span>, parentWeb.Locale); } <span style="COLOR: #008000">//if we have the
parent workflow, we need to copy the review settings to the child</span><span style="COLOR: #0000ff">if</span> (parentWorkflowAssociation
!= <span style="COLOR: #0000ff">null</span>) { <span style="COLOR: #008000">//xmldoc
for the parent association data</span> XmlDocument parentAssociationData = <span style="COLOR: #0000ff">new</span> XmlDocument();
parentAssociationData.LoadXml(parentWorkflowAssociation.AssociationData); <span style="COLOR: #008000">//xmldoc
for the child workflow association data</span> XmlDocument currentAssociationData
= <span style="COLOR: #0000ff">new</span> XmlDocument(); currentAssociationData.LoadXml(currentWorkflowAssociation.AssociationData); <span style="COLOR: #008000">//we
need to create a namespace manager object because the xml data we want is </span><span style="COLOR: #008000">//namespaced
with 'xmlns:my="http://schemas.microsoft.com/office/infopath/2003/myXSD"'</span><span style="COLOR: #008000">//the
following code was obtained from John Wood's blog</span><span style="COLOR: #008000">//url:
http://www.dotnetjunkies.com/WebLog/johnwood/archive/2005/08/25/132153.aspx</span><span style="COLOR: #008000">//this
code will add all namespaces in the xml to the namespace manager, allowing us to correctly</span><span style="COLOR: #008000">//create
XPath queries to retrive the data we need</span> XmlNamespaceManager nsmgr = <span style="COLOR: #0000ff">new</span> XmlNamespaceManager(parentAssociationData.NameTable); <span style="COLOR: #0000ff">foreach</span> (XmlAttribute
attr <span style="COLOR: #0000ff">in</span> parentAssociationData.SelectSingleNode(<span style="COLOR: #006080">"/*"</span>).Attributes)
{ <span style="COLOR: #0000ff">if</span> (attr.Prefix == <span style="COLOR: #006080">"xmlns"</span>)
nsmgr.AddNamespace(attr.LocalName, attr.Value); } <span style="COLOR: #008000">//get
the Reviewers node from the parent workflow</span> XmlNode parentReviewers = parentAssociationData.SelectSingleNode(<span style="COLOR: #006080">"//my:Reviewers"</span>,
nsmgr); <span style="COLOR: #008000">//get the Reviewers node from the child workflow</span> XmlNode
currentReviewers = currentAssociationData.SelectSingleNode(<span style="COLOR: #006080">"//my:Reviewers"</span>,
nsmgr); <span style="COLOR: #008000">//set the Reviewer node of the child workflow
to be the same as the parent</span> currentReviewers.InnerXml = parentReviewers.InnerXml; <span style="COLOR: #008000">//update
the child workflow's association data</span> currentWorkflowAssociation.AssociationData
= currentAssociationData.OuterXml; <span style="COLOR: #008000">//update the child
workflow association in the database</span> currentWebPublishingList.UpdateWorkflowAssociation(currentWorkflowAssociation);
} } <span style="COLOR: #008000">//make sure you dispose of the parentWeb object</span> parentWeb.Dispose();
} <span style="COLOR: #0000ff">public</span><span style="COLOR: #0000ff">override</span><span style="COLOR: #0000ff">void</span> FeatureDeactivating(SPFeatureReceiverProperties
properties) { } <span style="COLOR: #0000ff">public</span><span style="COLOR: #0000ff">override</span><span style="COLOR: #0000ff">void</span> FeatureInstalled(SPFeatureReceiverProperties
properties) { } <span style="COLOR: #0000ff">public</span><span style="COLOR: #0000ff">override</span><span style="COLOR: #0000ff">void</span> FeatureUninstalling(SPFeatureReceiverProperties
properties) { } } } 
</p>
          </pre>
        </div>
        <img width="0" height="0" src="http://blog.richfinn.net/blog/aggbug.ashx?id=55cbf57f-6d3d-444e-aa45-6b9335301260" />
      </body>
      <title>Publishing Web: Inherit Parent Web's Workflow Settings</title>
      <guid isPermaLink="false">http://blog.richfinn.net/blog/PermaLink,guid,55cbf57f-6d3d-444e-aa45-6b9335301260.aspx</guid>
      <link>http://blog.richfinn.net/blog/2008/06/20/PublishingWebInheritParentWebsWorkflowSettings.aspx</link>
      <pubDate>Fri, 20 Jun 2008 18:42:55 GMT</pubDate>
      <description>&lt;p&gt;
In our current SharePoint project, we have a custom site definition based on the out-of-box
Publishing Site with Workflow. We found a little problem with this though, because
when the out-of-box Features for Publishing and it's Parallel Approval workflow are
activated, the default SharePoint Approvers group is the only group that is set to
approve a publishing page that has been sent into the workflow. The problem is, we
want to inherit the parent site's workflow settings - otherwise known as the association
data - because our application has 'channels' of content that each has a different
group who can approve the content in their appropriate channel.
&lt;/p&gt;
&lt;p&gt;
The group that can approve publishing pages in each channel is defined in the root
web of the channel by doing nothing more than editing the Parallel Approval workflow
on the Pages list, and then setting the correct group on the People Picker for the
workflow approvers property. Since channel owners can create new sites in their channel
using our custom provisioning process, we don't want them to have to go into the Pages
list workflow settings to set the correct group every time, because as we all know,
people make mistakes. Why not automate this process and set the right approvers group
for the channel owner when the new site is created?
&lt;/p&gt;
&lt;p&gt;
To do this, we created a Feature that we &lt;a href="http://www.sharepointnutsandbolts.com/2007/05/feature-stapling.html" target=_blank&gt;included
in our custom site definition&lt;/a&gt;.&amp;nbsp; When a new site is created and the Feature
is activated, we execute the following code:
&lt;/p&gt;
&lt;div style="BORDER-RIGHT: gray 1px solid; PADDING-RIGHT: 4px; BORDER-TOP: gray 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 8pt; PADDING-BOTTOM: 4px; MARGIN: 20px 0px 10px; OVERFLOW: auto; BORDER-LEFT: gray 1px solid; WIDTH: 97.5%; CURSOR: text; LINE-HEIGHT: 12pt; PADDING-TOP: 4px; BORDER-BOTTOM: gray 1px solid; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BACKGROUND-COLOR: #f4f4f4"&gt;&lt;pre style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none"&gt;
&lt;p&gt;
&lt;span style="COLOR: #0000ff"&gt;using&lt;/span&gt; System; &lt;span style="COLOR: #0000ff"&gt;using&lt;/span&gt; System.Collections.Generic; &lt;span style="COLOR: #0000ff"&gt;using&lt;/span&gt; System.Text; &lt;span style="COLOR: #0000ff"&gt;using&lt;/span&gt; Microsoft.SharePoint; &lt;span style="COLOR: #0000ff"&gt;using&lt;/span&gt; System.Diagnostics; &lt;span style="COLOR: #0000ff"&gt;using&lt;/span&gt; Microsoft.SharePoint.Workflow; &lt;span style="COLOR: #0000ff"&gt;using&lt;/span&gt; System.Xml; &lt;span style="COLOR: #0000ff"&gt;using&lt;/span&gt; Microsoft.SharePoint.Publishing; &lt;span style="COLOR: #0000ff"&gt;namespace&lt;/span&gt; Demo
{ &lt;span style="COLOR: #0000ff"&gt;public&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;class&lt;/span&gt; FeatureReceiver
: SPFeatureReceiver { &lt;span style="COLOR: #0000ff"&gt;public&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;override&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;void&lt;/span&gt; FeatureActivated(SPFeatureReceiverProperties
properties) { &lt;span style="COLOR: #008000"&gt;//get the SPWeb object for the Feature's
scope&lt;/span&gt; SPWeb currentWeb = properties.Feature.Parent &lt;span style="COLOR: #0000ff"&gt;as&lt;/span&gt; SPWeb; &lt;span style="COLOR: #008000"&gt;//set
the AllowUnsafeUpdates property to true so we can apply the change to the workflow&lt;/span&gt; currentWeb.AllowUnsafeUpdates
= &lt;span style="COLOR: #0000ff"&gt;true&lt;/span&gt;; &lt;span style="COLOR: #008000"&gt;//get the
parent web of the current web - this is where the correct workflow settings are&lt;/span&gt; SPWeb
parentWeb = currentWeb.ParentWeb; &lt;span style="COLOR: #008000"&gt;//get the Pages list
from the current web using the PublishingWeb object&lt;/span&gt; SPList currentWebPublishingList
= PublishingWeb.GetPublishingWeb(currentWeb).PagesList; &lt;span style="COLOR: #008000"&gt;//get
the current web Pages list's workflows&lt;/span&gt; SPWorkflowAssociationCollection currentWebWorkflows
= currentWebPublishingList.WorkflowAssociations; &lt;span style="COLOR: #008000"&gt;//if
the site has workflows, we need to get the parent web's workflow and apply the same
approvers to it&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;if&lt;/span&gt; (currentWebWorkflows.Count
&amp;gt;= 1) { &lt;span style="COLOR: #008000"&gt;//find the parallel approval workflow&lt;/span&gt; SPWorkflowAssociation
currentWorkflowAssociation = currentWebWorkflows.GetAssociationByName(&lt;span style="COLOR: #006080"&gt;"Parallel
Approval"&lt;/span&gt;, currentWeb.Locale); &lt;span style="COLOR: #008000"&gt;//empty container
for the parent pages list workflow&lt;/span&gt; SPWorkflowAssociation parentWorkflowAssociation
= &lt;span style="COLOR: #0000ff"&gt;null&lt;/span&gt;; &lt;span style="COLOR: #008000"&gt;//get the
parent site's pages list&lt;/span&gt; SPList parentPagesList = PublishingWeb.GetPublishingWeb(parentWeb).PagesList; &lt;span style="COLOR: #008000"&gt;//if
there's workflows attached, we need to find the Parallel Approval workflow&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;if&lt;/span&gt; (parentPagesList.WorkflowAssociations.Count
&amp;gt; 0) { parentWorkflowAssociation = parentPagesList.WorkflowAssociations.GetAssociationByName(&lt;span style="COLOR: #006080"&gt;"Parallel
Approval"&lt;/span&gt;, parentWeb.Locale); } &lt;span style="COLOR: #008000"&gt;//if we have the
parent workflow, we need to copy the review settings to the child&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;if&lt;/span&gt; (parentWorkflowAssociation
!= &lt;span style="COLOR: #0000ff"&gt;null&lt;/span&gt;) { &lt;span style="COLOR: #008000"&gt;//xmldoc
for the parent association data&lt;/span&gt; XmlDocument parentAssociationData = &lt;span style="COLOR: #0000ff"&gt;new&lt;/span&gt; XmlDocument();
parentAssociationData.LoadXml(parentWorkflowAssociation.AssociationData); &lt;span style="COLOR: #008000"&gt;//xmldoc
for the child workflow association data&lt;/span&gt; XmlDocument currentAssociationData
= &lt;span style="COLOR: #0000ff"&gt;new&lt;/span&gt; XmlDocument(); currentAssociationData.LoadXml(currentWorkflowAssociation.AssociationData); &lt;span style="COLOR: #008000"&gt;//we
need to create a namespace manager object because the xml data we want is &lt;/span&gt; &lt;span style="COLOR: #008000"&gt;//namespaced
with 'xmlns:my="http://schemas.microsoft.com/office/infopath/2003/myXSD"'&lt;/span&gt; &lt;span style="COLOR: #008000"&gt;//the
following code was obtained from John Wood's blog&lt;/span&gt; &lt;span style="COLOR: #008000"&gt;//url:
http://www.dotnetjunkies.com/WebLog/johnwood/archive/2005/08/25/132153.aspx&lt;/span&gt; &lt;span style="COLOR: #008000"&gt;//this
code will add all namespaces in the xml to the namespace manager, allowing us to correctly&lt;/span&gt; &lt;span style="COLOR: #008000"&gt;//create
XPath queries to retrive the data we need&lt;/span&gt; XmlNamespaceManager nsmgr = &lt;span style="COLOR: #0000ff"&gt;new&lt;/span&gt; XmlNamespaceManager(parentAssociationData.NameTable); &lt;span style="COLOR: #0000ff"&gt;foreach&lt;/span&gt; (XmlAttribute
attr &lt;span style="COLOR: #0000ff"&gt;in&lt;/span&gt; parentAssociationData.SelectSingleNode(&lt;span style="COLOR: #006080"&gt;"/*"&lt;/span&gt;).Attributes)
{ &lt;span style="COLOR: #0000ff"&gt;if&lt;/span&gt; (attr.Prefix == &lt;span style="COLOR: #006080"&gt;"xmlns"&lt;/span&gt;)
nsmgr.AddNamespace(attr.LocalName, attr.Value); } &lt;span style="COLOR: #008000"&gt;//get
the Reviewers node from the parent workflow&lt;/span&gt; XmlNode parentReviewers = parentAssociationData.SelectSingleNode(&lt;span style="COLOR: #006080"&gt;"//my:Reviewers"&lt;/span&gt;,
nsmgr); &lt;span style="COLOR: #008000"&gt;//get the Reviewers node from the child workflow&lt;/span&gt; XmlNode
currentReviewers = currentAssociationData.SelectSingleNode(&lt;span style="COLOR: #006080"&gt;"//my:Reviewers"&lt;/span&gt;,
nsmgr); &lt;span style="COLOR: #008000"&gt;//set the Reviewer node of the child workflow
to be the same as the parent&lt;/span&gt; currentReviewers.InnerXml = parentReviewers.InnerXml; &lt;span style="COLOR: #008000"&gt;//update
the child workflow's association data&lt;/span&gt; currentWorkflowAssociation.AssociationData
= currentAssociationData.OuterXml; &lt;span style="COLOR: #008000"&gt;//update the child
workflow association in the database&lt;/span&gt; currentWebPublishingList.UpdateWorkflowAssociation(currentWorkflowAssociation);
} } &lt;span style="COLOR: #008000"&gt;//make sure you dispose of the parentWeb object&lt;/span&gt; parentWeb.Dispose();
} &lt;span style="COLOR: #0000ff"&gt;public&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;override&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;void&lt;/span&gt; FeatureDeactivating(SPFeatureReceiverProperties
properties) { } &lt;span style="COLOR: #0000ff"&gt;public&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;override&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;void&lt;/span&gt; FeatureInstalled(SPFeatureReceiverProperties
properties) { } &lt;span style="COLOR: #0000ff"&gt;public&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;override&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;void&lt;/span&gt; FeatureUninstalling(SPFeatureReceiverProperties
properties) { } } } 
&lt;/p&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;img width="0" height="0" src="http://blog.richfinn.net/blog/aggbug.ashx?id=55cbf57f-6d3d-444e-aa45-6b9335301260" /&gt;</description>
      <comments>http://blog.richfinn.net/blog/CommentView,guid,55cbf57f-6d3d-444e-aa45-6b9335301260.aspx</comments>
      <category>Development</category>
      <category>Microsoft Office SharePoint Server</category>
    </item>
    <item>
      <trackback:ping>http://blog.richfinn.net/blog/Trackback.aspx?guid=fab8d632-7073-46b4-8f92-fb595b6a41ec</trackback:ping>
      <pingback:server>http://blog.richfinn.net/blog/pingback.aspx</pingback:server>
      <pingback:target>http://blog.richfinn.net/blog/PermaLink,guid,fab8d632-7073-46b4-8f92-fb595b6a41ec.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://blog.richfinn.net/blog/CommentView,guid,fab8d632-7073-46b4-8f92-fb595b6a41ec.aspx</wfw:comment>
      <wfw:commentRss>http://blog.richfinn.net/blog/SyndicationService.asmx/GetEntryCommentsRss?guid=fab8d632-7073-46b4-8f92-fb595b6a41ec</wfw:commentRss>
      <slash:comments>3</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I just updated the <a href="http://www.codeplex.com/ajaxifymoss">Ajaxify MOSS</a> codeplex release
to include the needed web.config entries for using the .Net 3.5 version of System.Web.Extensions.
</p>
        <p>
There is, however, one manual step you still have to perform to the web.config files
in order to get this to work right. You still need to add the dependentAssembly elements
to the configuration/runtime/assemblyBinding element, as shown below:<br />
 <a href="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/AjaxifyMOSSnowfeaturing.Net3.5_DEE1/image_4.png"><img style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height="223" alt="image" src="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/AjaxifyMOSSnowfeaturing.Net3.5_DEE1/image_thumb_1.png" width="692" border="0" /></a></p>
        <p>
I tried a whole bunch of different ways to get the xpath in the SPWebConfigModification
object to try and get it to work, but I think the problem is that it's either too
ambiguous because there's no unique identifier available on the dependentAssembly
element, or the namespace on the assemblyBinding element is causing problems.
</p>
        <p>
All the other entries are being applied correctly, though.  Also, I try and help
out a little by outputting the nodes in the stsadm command output after the nodes
are applied :) - see:<br /><a href="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/AjaxifyMOSSnowfeaturing.Net3.5_DEE1/image_6.png"><img style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height="249" alt="image" src="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/AjaxifyMOSSnowfeaturing.Net3.5_DEE1/image_thumb_2.png" width="644" border="0" /></a></p>
        <p>
Just mark and copy the lines from there, and you're halfway there.
</p>
        <p>
The command names are on the releases tab in the codeplex project.  If you're
upgrading from the ASP.Net AJAX 1.0 framework, make sure you uninstall the config
mods first, before you add the 3.5 config mods.
</p>
        <p>
Final note: I hope to be adding the needed lines for SilverLight pretty soon.
</p>
        <img width="0" height="0" src="http://blog.richfinn.net/blog/aggbug.ashx?id=fab8d632-7073-46b4-8f92-fb595b6a41ec" />
      </body>
      <title>Ajaxify MOSS - now featuring .Net 3.5</title>
      <guid isPermaLink="false">http://blog.richfinn.net/blog/PermaLink,guid,fab8d632-7073-46b4-8f92-fb595b6a41ec.aspx</guid>
      <link>http://blog.richfinn.net/blog/2008/06/19/AjaxifyMOSSNowFeaturingNet35.aspx</link>
      <pubDate>Thu, 19 Jun 2008 21:51:02 GMT</pubDate>
      <description>&lt;p&gt;
I just updated the &lt;a href="http://www.codeplex.com/ajaxifymoss"&gt;Ajaxify MOSS&lt;/a&gt; codeplex&amp;nbsp;release
to include the needed web.config entries for using the .Net 3.5 version of System.Web.Extensions.
&lt;/p&gt;
&lt;p&gt;
There is, however, one manual step you still have to perform to the web.config files
in order to get this to work right. You still need to add the dependentAssembly elements
to the configuration/runtime/assemblyBinding element, as shown below:&lt;br&gt;
&amp;nbsp;&lt;a href="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/AjaxifyMOSSnowfeaturing.Net3.5_DEE1/image_4.png"&gt;&lt;img style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height=223 alt=image src="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/AjaxifyMOSSnowfeaturing.Net3.5_DEE1/image_thumb_1.png" width=692 border=0&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
I tried a whole bunch of different ways to get the xpath in the SPWebConfigModification
object to try and get it to work, but I think the problem is that it's either too
ambiguous because there's no unique identifier available on the dependentAssembly
element, or the namespace on the assemblyBinding element is causing problems.
&lt;/p&gt;
&lt;p&gt;
All the other entries are being applied correctly, though.&amp;nbsp; Also, I try and help
out a little by outputting the nodes in the stsadm command output after the nodes
are applied :) - see:&lt;br&gt;
&lt;a href="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/AjaxifyMOSSnowfeaturing.Net3.5_DEE1/image_6.png"&gt;&lt;img style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height=249 alt=image src="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/AjaxifyMOSSnowfeaturing.Net3.5_DEE1/image_thumb_2.png" width=644 border=0&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
Just mark and copy the lines from there, and you're halfway there.
&lt;/p&gt;
&lt;p&gt;
The command names are on the releases tab in the codeplex project.&amp;nbsp; If you're
upgrading from the ASP.Net AJAX 1.0 framework, make sure you uninstall the config
mods first, before you add the 3.5 config mods.
&lt;/p&gt;
&lt;p&gt;
Final note: I hope to be adding the needed lines for SilverLight pretty soon.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://blog.richfinn.net/blog/aggbug.ashx?id=fab8d632-7073-46b4-8f92-fb595b6a41ec" /&gt;</description>
      <comments>http://blog.richfinn.net/blog/CommentView,guid,fab8d632-7073-46b4-8f92-fb595b6a41ec.aspx</comments>
      <category>Development</category>
      <category>Microsoft Office SharePoint Server</category>
    </item>
    <item>
      <trackback:ping>http://blog.richfinn.net/blog/Trackback.aspx?guid=5a4e9d4a-2fc0-4fec-96e3-507d04c8275a</trackback:ping>
      <pingback:server>http://blog.richfinn.net/blog/pingback.aspx</pingback:server>
      <pingback:target>http://blog.richfinn.net/blog/PermaLink,guid,5a4e9d4a-2fc0-4fec-96e3-507d04c8275a.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://blog.richfinn.net/blog/CommentView,guid,5a4e9d4a-2fc0-4fec-96e3-507d04c8275a.aspx</wfw:comment>
      <wfw:commentRss>http://blog.richfinn.net/blog/SyndicationService.asmx/GetEntryCommentsRss?guid=5a4e9d4a-2fc0-4fec-96e3-507d04c8275a</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
A few days ago, I mentioned that we're trying to automate as much as possible in our
new SharePoint based product, and I explained how we are <a href="http://blog.richfinn.net/blog/2008/06/17/CreateSearchScopeInFeatureReceiver.aspx" target="_blank">creating
custom search scopes in a Feature Receiver</a>.
</p>
        <p>
Another component we're automating is the creation of Crawl Rules for the search engine
in the SSP the site collection is associated.
</p>
        <p>
          <a href="http://msdn.microsoft.com/en-us/library/ms562090.aspx" target="_blank">According
to MSDN</a> crawl rules are defined as follows:
</p>
        <blockquote>
          <p>
Crawl rules provide you with the ability to set the behavior of the Enterprise Search
index engine when you want to crawl content from a particular path. By using these
rules, you can: 
</p>
          <ul>
            <li>
              <p>
Prevent content within a particular path from being crawled.  
</p>
            </li>
            <li>
              <p>
Indicate that a particular path that would otherwise be excluded from the crawl should
be crawled.
</p>
            </li>
          </ul>
        </blockquote>
        <p>
Here's how we're creating the crawl rules in code using a similar Feature Receiver
as before:
</p>
        <div style="BORDER-RIGHT: gray 1px solid; PADDING-RIGHT: 4px; BORDER-TOP: gray 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 8pt; PADDING-BOTTOM: 4px; MARGIN: 20px 0px 10px; OVERFLOW: auto; BORDER-LEFT: gray 1px solid; WIDTH: 97.5%; CURSOR: text; LINE-HEIGHT: 12pt; PADDING-TOP: 4px; BORDER-BOTTOM: gray 1px solid; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BACKGROUND-COLOR: #f4f4f4">
          <pre style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none">
            <span style="COLOR: #0000ff">using</span> System; <span style="COLOR: #0000ff">using</span> System.Collections.Generic; <span style="COLOR: #0000ff">using</span> System.Text; <span style="COLOR: #0000ff">using</span> Microsoft.SharePoint; <span style="COLOR: #0000ff">using</span> Microsoft.Office.Server.Search.Administration; <span style="COLOR: #0000ff">using</span> System.Diagnostics; <span style="COLOR: #0000ff">public</span><span style="COLOR: #0000ff">class</span> FeatureReceiver
: SPFeatureReceiver { SPSite currentSite = <span style="COLOR: #0000ff">null</span>; <span style="COLOR: #0000ff">public</span><span style="COLOR: #0000ff">override</span><span style="COLOR: #0000ff">void</span> FeatureActivated(SPFeatureReceiverProperties
properties) { <span style="COLOR: #008000">//Debugger.Launch();</span><span style="COLOR: #0000ff">this</span>.currentSite
= properties.Feature.Parent <span style="COLOR: #0000ff">as</span> SPSite; createCrawlRules();
} <span style="COLOR: #0000ff">private</span><span style="COLOR: #0000ff">void</span> createCrawlRules()
{ <span style="COLOR: #008000">//get the site SSP's search server instance</span> SearchContext
searchContext = SearchContext.GetContext(<span style="COLOR: #0000ff">this</span>.currentSite); <span style="COLOR: #008000">//For
this example, I'll just show how to exclude the Explorer view of a list</span><span style="COLOR: #008000">//Notice
how we're using wildcard characters to specify that every /Forms/WebFldr.aspx page</span><span style="COLOR: #008000">//
will be excluded regaurdless of protocol or location in the site collection</span><span style="COLOR: #0000ff">string</span> crawlRule
= <span style="COLOR: #006080">" *://*/Forms/WebFldr.aspx"</span>; <span style="COLOR: #008000">//get
the content source for the search server</span> Content sspContent = <span style="COLOR: #0000ff">new</span> Content(searchContext); <span style="COLOR: #008000">//check
to see if the crawl rule exists, and create it if it doesn't</span><span style="COLOR: #0000ff">if</span> (!sspContent.CrawlRules.Exists(rule))
{ </pre>
          <pre style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none">
            <p>
              <span style="COLOR: #008000">//create the crawl rule, setting the type of crawl rule
and the crawl rule string</span> CrawlRule crawlRule = sspContent.CrawlRules.Create(CrawlRuleType.ExclusionRule,
rule); <span style="COLOR: #008000">//we want to make sure that the rule still works
if there are querystring variables</span> crawlRule.FollowComplexUrls = <span style="COLOR: #0000ff">true</span>; <span style="COLOR: #008000">//at
this point, you can set other properties such as authentication information to crawl</span><span style="COLOR: #008000">//
content using a different identity or authentication method</span><span style="COLOR: #008000">//
for more info , check out <a href="http://technet.microsoft.com/en-us/library/cc263150(TechNet.10).aspx" target="_blank">http://technet.microsoft.com/en-us/library/cc263150(TechNet.10).aspx</a></span><span style="COLOR: #008000">//commit
the rule in the database</span> crawlRule.Update(); } } 
</p>
            <blockquote>
              <p>
                <span style="COLOR: #0000ff">public</span>
                <span style="COLOR: #0000ff">override</span>
                <span style="COLOR: #0000ff">void</span> FeatureDeactivating(SPFeatureReceiverProperties
properties){} 
</p>
              <p>
                <span style="COLOR: #0000ff">public</span>
                <span style="COLOR: #0000ff">override</span>
                <span style="COLOR: #0000ff">void</span> FeatureInstalled(SPFeatureReceiverProperties
properties){} 
</p>
              <p>
                <span style="COLOR: #0000ff">public</span>
                <span style="COLOR: #0000ff">override</span>
                <span style="COLOR: #0000ff">void</span> FeatureUninstalling(SPFeatureReceiverProperties
properties){} 
</p>
            </blockquote>
            <p>
}
</p>
          </pre>
        </div>
        <img width="0" height="0" src="http://blog.richfinn.net/blog/aggbug.ashx?id=5a4e9d4a-2fc0-4fec-96e3-507d04c8275a" />
      </body>
      <title>Create Search Crawl Rules Programmatically</title>
      <guid isPermaLink="false">http://blog.richfinn.net/blog/PermaLink,guid,5a4e9d4a-2fc0-4fec-96e3-507d04c8275a.aspx</guid>
      <link>http://blog.richfinn.net/blog/2008/06/19/CreateSearchCrawlRulesProgrammatically.aspx</link>
      <pubDate>Thu, 19 Jun 2008 18:58:28 GMT</pubDate>
      <description>&lt;p&gt;
A few days ago, I mentioned that we're trying to automate as much as possible in our
new SharePoint based product, and I explained how we are &lt;a href="http://blog.richfinn.net/blog/2008/06/17/CreateSearchScopeInFeatureReceiver.aspx" target=_blank&gt;creating
custom search scopes in a Feature Receiver&lt;/a&gt;.
&lt;/p&gt;
&lt;p&gt;
Another component we're automating is the creation of Crawl Rules for the search engine
in the SSP the site collection is associated.
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://msdn.microsoft.com/en-us/library/ms562090.aspx" target=_blank&gt;According
to MSDN&lt;/a&gt; crawl rules are defined as follows:
&lt;/p&gt;
&lt;blockquote&gt; 
&lt;p&gt;
Crawl rules provide you with the ability to set the behavior of the Enterprise Search
index engine when you want to crawl content from a particular path. By using these
rules, you can: 
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;
Prevent content within a particular path from being crawled.&amp;nbsp; 
&lt;/p&gt;
&lt;li&gt;
&lt;p&gt;
Indicate that a particular path that would otherwise be excluded from the crawl should
be crawled.
&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
Here's how we're creating the crawl rules in code using a similar Feature Receiver
as before:
&lt;/p&gt;
&lt;div style="BORDER-RIGHT: gray 1px solid; PADDING-RIGHT: 4px; BORDER-TOP: gray 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 8pt; PADDING-BOTTOM: 4px; MARGIN: 20px 0px 10px; OVERFLOW: auto; BORDER-LEFT: gray 1px solid; WIDTH: 97.5%; CURSOR: text; LINE-HEIGHT: 12pt; PADDING-TOP: 4px; BORDER-BOTTOM: gray 1px solid; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BACKGROUND-COLOR: #f4f4f4"&gt;&lt;pre style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none"&gt;&lt;span style="COLOR: #0000ff"&gt;using&lt;/span&gt; System; &lt;span style="COLOR: #0000ff"&gt;using&lt;/span&gt; System.Collections.Generic; &lt;span style="COLOR: #0000ff"&gt;using&lt;/span&gt; System.Text; &lt;span style="COLOR: #0000ff"&gt;using&lt;/span&gt; Microsoft.SharePoint; &lt;span style="COLOR: #0000ff"&gt;using&lt;/span&gt; Microsoft.Office.Server.Search.Administration; &lt;span style="COLOR: #0000ff"&gt;using&lt;/span&gt; System.Diagnostics; &lt;span style="COLOR: #0000ff"&gt;public&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;class&lt;/span&gt; FeatureReceiver
: SPFeatureReceiver { SPSite currentSite = &lt;span style="COLOR: #0000ff"&gt;null&lt;/span&gt;; &lt;span style="COLOR: #0000ff"&gt;public&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;override&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;void&lt;/span&gt; FeatureActivated(SPFeatureReceiverProperties
properties) { &lt;span style="COLOR: #008000"&gt;//Debugger.Launch();&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;this&lt;/span&gt;.currentSite
= properties.Feature.Parent &lt;span style="COLOR: #0000ff"&gt;as&lt;/span&gt; SPSite; createCrawlRules();
} &lt;span style="COLOR: #0000ff"&gt;private&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;void&lt;/span&gt; createCrawlRules()
{ &lt;span style="COLOR: #008000"&gt;//get the site SSP's search server instance&lt;/span&gt; SearchContext
searchContext = SearchContext.GetContext(&lt;span style="COLOR: #0000ff"&gt;this&lt;/span&gt;.currentSite); &lt;span style="COLOR: #008000"&gt;//For
this example, I'll just show how to exclude the Explorer view of a list&lt;/span&gt; &lt;span style="COLOR: #008000"&gt;//Notice
how we're using wildcard characters to specify that every /Forms/WebFldr.aspx page&lt;/span&gt; &lt;span style="COLOR: #008000"&gt;//
will be excluded regaurdless of protocol or location in the site collection&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;string&lt;/span&gt; crawlRule
= &lt;span style="COLOR: #006080"&gt;" *://*/Forms/WebFldr.aspx"&lt;/span&gt;; &lt;span style="COLOR: #008000"&gt;//get
the content source for the search server&lt;/span&gt; Content sspContent = &lt;span style="COLOR: #0000ff"&gt;new&lt;/span&gt; Content(searchContext); &lt;span style="COLOR: #008000"&gt;//check
to see if the crawl rule exists, and create it if it doesn't&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;if&lt;/span&gt; (!sspContent.CrawlRules.Exists(rule))
{ &lt;/pre&gt;&lt;pre style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none"&gt;
&lt;p&gt;
&lt;span style="COLOR: #008000"&gt;//create the crawl rule, setting the type of crawl rule
and the crawl rule string&lt;/span&gt; CrawlRule crawlRule = sspContent.CrawlRules.Create(CrawlRuleType.ExclusionRule,
rule); &lt;span style="COLOR: #008000"&gt;//we want to make sure that the rule still works
if there are querystring variables&lt;/span&gt; crawlRule.FollowComplexUrls = &lt;span style="COLOR: #0000ff"&gt;true&lt;/span&gt;; &lt;span style="COLOR: #008000"&gt;//at
this point, you can set other properties such as authentication information to crawl&lt;/span&gt; &lt;span style="COLOR: #008000"&gt;//
content using a different identity or authentication method&lt;/span&gt; &lt;span style="COLOR: #008000"&gt;//
for more info , check out &lt;a href="http://technet.microsoft.com/en-us/library/cc263150(TechNet.10).aspx" target=_blank&gt;http://technet.microsoft.com/en-us/library/cc263150(TechNet.10).aspx&lt;/a&gt;&lt;/span&gt; &lt;span style="COLOR: #008000"&gt;//commit
the rule in the database&lt;/span&gt; crawlRule.Update(); } } 
&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;
&lt;span style="COLOR: #0000ff"&gt;public&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;override&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;void&lt;/span&gt; FeatureDeactivating(SPFeatureReceiverProperties
properties){} 
&lt;/p&gt;
&lt;p&gt;
&lt;span style="COLOR: #0000ff"&gt;public&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;override&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;void&lt;/span&gt; FeatureInstalled(SPFeatureReceiverProperties
properties){} 
&lt;/p&gt;
&lt;p&gt;
&lt;span style="COLOR: #0000ff"&gt;public&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;override&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;void&lt;/span&gt; FeatureUninstalling(SPFeatureReceiverProperties
properties){} 
&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;
}
&lt;/p&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;img width="0" height="0" src="http://blog.richfinn.net/blog/aggbug.ashx?id=5a4e9d4a-2fc0-4fec-96e3-507d04c8275a" /&gt;</description>
      <comments>http://blog.richfinn.net/blog/CommentView,guid,5a4e9d4a-2fc0-4fec-96e3-507d04c8275a.aspx</comments>
      <category>Development</category>
      <category>Microsoft Office SharePoint Server</category>
    </item>
    <item>
      <trackback:ping>http://blog.richfinn.net/blog/Trackback.aspx?guid=9b1a6c79-5750-4ed8-a063-84719caf0c85</trackback:ping>
      <pingback:server>http://blog.richfinn.net/blog/pingback.aspx</pingback:server>
      <pingback:target>http://blog.richfinn.net/blog/PermaLink,guid,9b1a6c79-5750-4ed8-a063-84719caf0c85.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://blog.richfinn.net/blog/CommentView,guid,9b1a6c79-5750-4ed8-a063-84719caf0c85.aspx</wfw:comment>
      <wfw:commentRss>http://blog.richfinn.net/blog/SyndicationService.asmx/GetEntryCommentsRss?guid=9b1a6c79-5750-4ed8-a063-84719caf0c85</wfw:commentRss>
      <slash:comments>1</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I've recently been working on a SharePoint project which is being offered to clients
as a product built on top of the SharePoint framework.  While I can't describe
in too much detail exactly what the product is, I figured it might be beneficial to
discuss how we've built out certain aspects of the solution.  At the very least,
I can compile some notes of my own so I can remember later how tackled some of the
issues we had during the dev process.
</p>
        <p>
To give a little background on the product, at the core, this is primarily a publishing-based
solution that is deployed into a site collection. One of the goals in the development
of the product has been to automate the creation of the site collection as much as
possible when a new client purchases the product.  We're handling the bulk of
the new client deployment through a Feature called 'Product.SiteConfiguration' that
when activated, executes a Feature Receiver that both creates some higher-level components
and populates 'default' data in areas of the site that are required for the product
to function properly.
</p>
        <p>
One of the things we're creating in the SiteConfiguration Feature Receiver is a locally
defined, custom search scope that is specific to the site collection of the product.
A search scope allows the narrowing of search results based on rules defined within
the scope, so we wanted to create a scope that is specific to the product so that
when a user searches from the product's generic search box, only items from within
the product are returned.
</p>
        <p>
Here's sample code used to create a new scope in a site collection:
</p>
        <div style="BORDER-RIGHT: gray 1px solid; PADDING-RIGHT: 4px; BORDER-TOP: gray 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 8pt; PADDING-BOTTOM: 4px; MARGIN: 20px 0px 10px; OVERFLOW: auto; BORDER-LEFT: gray 1px solid; WIDTH: 97.5%; CURSOR: text; LINE-HEIGHT: 12pt; PADDING-TOP: 4px; BORDER-BOTTOM: gray 1px solid; FONT-FAMILY: consolas, 'Courier New', courier, monospace; HEIGHT: 1145px; BACKGROUND-COLOR: #f4f4f4">
          <pre style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; HEIGHT: 1143px; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none">
            <span style="COLOR: #0000ff">using</span> System; <span style="COLOR: #0000ff">using</span> System.Collections.Generic; <span style="COLOR: #0000ff">using</span> System.Text; <span style="COLOR: #0000ff">using</span> Microsoft.SharePoint; <span style="COLOR: #0000ff">using</span> Microsoft.Office.Server.Search.Administration; <span style="COLOR: #0000ff">using</span> System.Diagnostics; <span style="COLOR: #0000ff">namespace</span> LocalDev.Demo.Code
{ <span style="COLOR: #0000ff">public</span><span style="COLOR: #0000ff">class</span> SiteConfiguration
: SPFeatureReceiver { SPSite currentSite = <span style="COLOR: #0000ff">null</span>; <span style="COLOR: #0000ff">public</span><span style="COLOR: #0000ff">override</span><span style="COLOR: #0000ff">void</span> FeatureActivated(SPFeatureReceiverProperties
properties) { <span style="COLOR: #0000ff">string</span> scopeName = <span style="COLOR: #006080">"ProductScope"</span>; <span style="COLOR: #0000ff">this</span>.currentSite
= properties.Feature.Parent <span style="COLOR: #0000ff">as</span> SPSite; <span style="COLOR: #008000">//get
the site SSP's search server instance</span> SearchContext searchContext = SearchContext.GetContext(<span style="COLOR: #0000ff">this</span>.currentSite); <span style="COLOR: #008000">//get
the current scopes defined in the search server</span> Scopes scopes = <span style="COLOR: #0000ff">new</span> Scopes(searchContext); <span style="COLOR: #008000">//create
a URI object for the current site - used in checking for the scope we're creating</span><span style="COLOR: #0000ff">string</span> siteUrl
= <span style="COLOR: #0000ff">this</span>.currentSite.Url; Uri siteUri = <span style="COLOR: #0000ff">new</span> Uri(siteUrl); <span style="COLOR: #008000">//create
scope object for the new scope</span> Scope newScope = <span style="COLOR: #0000ff">null</span>; <span style="COLOR: #0000ff">try</span> { <span style="COLOR: #008000">//this
is a little bit of a hack, but if it bombs, we know the scope doesn't exist</span> newScope
= scopes.GetScope(siteUri, scopeName); } <span style="COLOR: #0000ff">catch</span> { <span style="COLOR: #008000">//create
the new scope</span> newScope = scopes.AllScopes.Create(scopeName, scopeName + <span style="COLOR: #006080">"
Description"</span>, siteUri, <span style="COLOR: #0000ff">true</span>, <span style="COLOR: #006080">"/_layouts/product/customsearchresults.aspx"</span>,
ScopeCompilationType.AlwaysCompile); <span style="COLOR: #008000">//create the scopes
rules for the new scope</span><span style="COLOR: #008000">//for example, include
content from the site</span> newScope.Rules.CreateUrlRule(ScopeRuleFilterBehavior.Include,
UrlScopeRuleType.Folder, siteUrl); <span style="COLOR: #008000">//save the changes
to the SSP Content Database</span> scopes.Update(); <span style="COLOR: #008000">//start
compilation of the scope</span> scopes.StartCompilation(); } } <span style="COLOR: #0000ff">public</span><span style="COLOR: #0000ff">override</span><span style="COLOR: #0000ff">void</span> FeatureDeactivating(SPFeatureReceiverProperties
properties) { } <span style="COLOR: #0000ff">public</span><span style="COLOR: #0000ff">override</span><span style="COLOR: #0000ff">void</span> FeatureInstalled(SPFeatureReceiverProperties
properties) { } <span style="COLOR: #0000ff">public</span><span style="COLOR: #0000ff">override</span><span style="COLOR: #0000ff">void</span> FeatureUninstalling(SPFeatureReceiverProperties
properties) { } } }</pre>
        </div>
        <img width="0" height="0" src="http://blog.richfinn.net/blog/aggbug.ashx?id=9b1a6c79-5750-4ed8-a063-84719caf0c85" />
      </body>
      <title>Create Search Scope in Feature Receiver</title>
      <guid isPermaLink="false">http://blog.richfinn.net/blog/PermaLink,guid,9b1a6c79-5750-4ed8-a063-84719caf0c85.aspx</guid>
      <link>http://blog.richfinn.net/blog/2008/06/17/CreateSearchScopeInFeatureReceiver.aspx</link>
      <pubDate>Tue, 17 Jun 2008 00:56:44 GMT</pubDate>
      <description>&lt;p&gt;
I've recently been working on a SharePoint project which is being offered to clients
as a product built on top of the SharePoint framework.&amp;nbsp; While I can't describe
in too much detail exactly what the product is, I figured it might be beneficial to
discuss how we've built out certain aspects of the solution.&amp;nbsp; At the very least,
I can compile some notes of my own so I can remember later how tackled some of the
issues we had during the dev process.
&lt;/p&gt;
&lt;p&gt;
To give a little background on the product, at the core, this is primarily a publishing-based
solution that is deployed into a site collection. One of the goals in the development
of the product has been to automate the creation of the site collection as much as
possible when a new client purchases the product.&amp;nbsp; We're handling the bulk of
the new client deployment through a Feature called 'Product.SiteConfiguration' that
when activated, executes a Feature Receiver that both creates some higher-level components
and populates 'default' data in areas of the site that are required for the product
to function properly.
&lt;/p&gt;
&lt;p&gt;
One of the things we're creating in the SiteConfiguration Feature Receiver is a locally
defined, custom search scope that is specific to the site collection of the product.
A search scope allows the narrowing of search results based on rules defined within
the scope, so we wanted to create a scope that is specific to the product so that
when a user searches from the product's generic search box, only items from within
the product are returned.
&lt;/p&gt;
&lt;p&gt;
Here's sample code used to create a new scope in a site collection:
&lt;/p&gt;
&lt;div style="BORDER-RIGHT: gray 1px solid; PADDING-RIGHT: 4px; BORDER-TOP: gray 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 8pt; PADDING-BOTTOM: 4px; MARGIN: 20px 0px 10px; OVERFLOW: auto; BORDER-LEFT: gray 1px solid; WIDTH: 97.5%; CURSOR: text; LINE-HEIGHT: 12pt; PADDING-TOP: 4px; BORDER-BOTTOM: gray 1px solid; FONT-FAMILY: consolas, 'Courier New', courier, monospace; HEIGHT: 1145px; BACKGROUND-COLOR: #f4f4f4"&gt;&lt;pre style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; HEIGHT: 1143px; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none"&gt;&lt;span style="COLOR: #0000ff"&gt;using&lt;/span&gt; System; &lt;span style="COLOR: #0000ff"&gt;using&lt;/span&gt; System.Collections.Generic; &lt;span style="COLOR: #0000ff"&gt;using&lt;/span&gt; System.Text; &lt;span style="COLOR: #0000ff"&gt;using&lt;/span&gt; Microsoft.SharePoint; &lt;span style="COLOR: #0000ff"&gt;using&lt;/span&gt; Microsoft.Office.Server.Search.Administration; &lt;span style="COLOR: #0000ff"&gt;using&lt;/span&gt; System.Diagnostics; &lt;span style="COLOR: #0000ff"&gt;namespace&lt;/span&gt; LocalDev.Demo.Code
{ &lt;span style="COLOR: #0000ff"&gt;public&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;class&lt;/span&gt; SiteConfiguration
: SPFeatureReceiver { SPSite currentSite = &lt;span style="COLOR: #0000ff"&gt;null&lt;/span&gt;; &lt;span style="COLOR: #0000ff"&gt;public&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;override&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;void&lt;/span&gt; FeatureActivated(SPFeatureReceiverProperties
properties) { &lt;span style="COLOR: #0000ff"&gt;string&lt;/span&gt; scopeName = &lt;span style="COLOR: #006080"&gt;"ProductScope"&lt;/span&gt;; &lt;span style="COLOR: #0000ff"&gt;this&lt;/span&gt;.currentSite
= properties.Feature.Parent &lt;span style="COLOR: #0000ff"&gt;as&lt;/span&gt; SPSite; &lt;span style="COLOR: #008000"&gt;//get
the site SSP's search server instance&lt;/span&gt; SearchContext searchContext = SearchContext.GetContext(&lt;span style="COLOR: #0000ff"&gt;this&lt;/span&gt;.currentSite); &lt;span style="COLOR: #008000"&gt;//get
the current scopes defined in the search server&lt;/span&gt; Scopes scopes = &lt;span style="COLOR: #0000ff"&gt;new&lt;/span&gt; Scopes(searchContext); &lt;span style="COLOR: #008000"&gt;//create
a URI object for the current site - used in checking for the scope we're creating&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;string&lt;/span&gt; siteUrl
= &lt;span style="COLOR: #0000ff"&gt;this&lt;/span&gt;.currentSite.Url; Uri siteUri = &lt;span style="COLOR: #0000ff"&gt;new&lt;/span&gt; Uri(siteUrl); &lt;span style="COLOR: #008000"&gt;//create
scope object for the new scope&lt;/span&gt; Scope newScope = &lt;span style="COLOR: #0000ff"&gt;null&lt;/span&gt;; &lt;span style="COLOR: #0000ff"&gt;try&lt;/span&gt; { &lt;span style="COLOR: #008000"&gt;//this
is a little bit of a hack, but if it bombs, we know the scope doesn't exist&lt;/span&gt; newScope
= scopes.GetScope(siteUri, scopeName); } &lt;span style="COLOR: #0000ff"&gt;catch&lt;/span&gt; { &lt;span style="COLOR: #008000"&gt;//create
the new scope&lt;/span&gt; newScope = scopes.AllScopes.Create(scopeName, scopeName + &lt;span style="COLOR: #006080"&gt;"
Description"&lt;/span&gt;, siteUri, &lt;span style="COLOR: #0000ff"&gt;true&lt;/span&gt;, &lt;span style="COLOR: #006080"&gt;"/_layouts/product/customsearchresults.aspx"&lt;/span&gt;,
ScopeCompilationType.AlwaysCompile); &lt;span style="COLOR: #008000"&gt;//create the scopes
rules for the new scope&lt;/span&gt; &lt;span style="COLOR: #008000"&gt;//for example, include
content from the site&lt;/span&gt; newScope.Rules.CreateUrlRule(ScopeRuleFilterBehavior.Include,
UrlScopeRuleType.Folder, siteUrl); &lt;span style="COLOR: #008000"&gt;//save the changes
to the SSP Content Database&lt;/span&gt; scopes.Update(); &lt;span style="COLOR: #008000"&gt;//start
compilation of the scope&lt;/span&gt; scopes.StartCompilation(); } } &lt;span style="COLOR: #0000ff"&gt;public&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;override&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;void&lt;/span&gt; FeatureDeactivating(SPFeatureReceiverProperties
properties) { } &lt;span style="COLOR: #0000ff"&gt;public&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;override&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;void&lt;/span&gt; FeatureInstalled(SPFeatureReceiverProperties
properties) { } &lt;span style="COLOR: #0000ff"&gt;public&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;override&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;void&lt;/span&gt; FeatureUninstalling(SPFeatureReceiverProperties
properties) { } } }&lt;/pre&gt;
&lt;/div&gt;
&lt;img width="0" height="0" src="http://blog.richfinn.net/blog/aggbug.ashx?id=9b1a6c79-5750-4ed8-a063-84719caf0c85" /&gt;</description>
      <comments>http://blog.richfinn.net/blog/CommentView,guid,9b1a6c79-5750-4ed8-a063-84719caf0c85.aspx</comments>
      <category>Development</category>
      <category>Microsoft Office SharePoint Server</category>
    </item>
    <item>
      <trackback:ping>http://blog.richfinn.net/blog/Trackback.aspx?guid=84906cb2-cc3c-4db8-a7b2-a8a77cd11645</trackback:ping>
      <pingback:server>http://blog.richfinn.net/blog/pingback.aspx</pingback:server>
      <pingback:target>http://blog.richfinn.net/blog/PermaLink,guid,84906cb2-cc3c-4db8-a7b2-a8a77cd11645.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://blog.richfinn.net/blog/CommentView,guid,84906cb2-cc3c-4db8-a7b2-a8a77cd11645.aspx</wfw:comment>
      <wfw:commentRss>http://blog.richfinn.net/blog/SyndicationService.asmx/GetEntryCommentsRss?guid=84906cb2-cc3c-4db8-a7b2-a8a77cd11645</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I've started getting tired of following the steps on Mike Ammerlaan's blog for <a href="http://sharepoint.microsoft.com/blogs/mike/Lists/Posts/Post.aspx?ID=3" target="_blank">Integrating
ASP.NET AJAX with SharePoint</a>.  It's not that the steps are difficult to follow,
but there's a lot of stuff you need to get right if you want to have all the ASP.NET
AJAX functionality available in MOSS.
</p>
        <p>
To ease my own pains with this process - and hopefully yours, too - I've published
to CodePlex some <a href="http://www.codeplex.com/ajaxifymoss" target="_blank">STSADM
extensions for adding and removing the needed ASP.NET AJAX</a> entries to the web.config
file. 
</p>
        <p>
Much thanks to <a href="http://stsadm.blogspot.com/" target="_blank">Gary Lapointe</a> for
providing the source code for <a href="http://stsadm.blogspot.com/2007/08/stsadm-commands_09.html" target="_blank">his
STSADM extensions</a>.  It served as a great starting place for me and decreased
the ramp-up time for creating my own custom STSADM commands tremendously.
</p>
        <p>
          <a href="http://www.codeplex.com/ajaxifymoss">View CodePlex site to download STSADM
extensions for ASP.NET AJAX</a>
        </p>
        <img width="0" height="0" src="http://blog.richfinn.net/blog/aggbug.ashx?id=84906cb2-cc3c-4db8-a7b2-a8a77cd11645" />
      </body>
      <title>STSADM Extensions for ASP.NET AJAX Configuration in MOSS</title>
      <guid isPermaLink="false">http://blog.richfinn.net/blog/PermaLink,guid,84906cb2-cc3c-4db8-a7b2-a8a77cd11645.aspx</guid>
      <link>http://blog.richfinn.net/blog/2008/05/12/STSADMExtensionsForASPNETAJAXConfigurationInMOSS.aspx</link>
      <pubDate>Mon, 12 May 2008 18:30:55 GMT</pubDate>
      <description>&lt;p&gt;
I've started getting tired of following the steps on Mike Ammerlaan's blog for &lt;a href="http://sharepoint.microsoft.com/blogs/mike/Lists/Posts/Post.aspx?ID=3" target=_blank&gt;Integrating
ASP.NET AJAX with SharePoint&lt;/a&gt;.&amp;nbsp; It's not that the steps are difficult to follow,
but there's a lot of stuff you need to get right if you want to have all the ASP.NET
AJAX functionality available in MOSS.
&lt;/p&gt;
&lt;p&gt;
To ease my own pains with this process - and hopefully yours, too - I've published
to CodePlex some &lt;a href="http://www.codeplex.com/ajaxifymoss" target=_blank&gt;STSADM
extensions for adding and removing the needed ASP.NET AJAX&lt;/a&gt; entries to the web.config
file. 
&lt;/p&gt;
&lt;p&gt;
Much thanks to &lt;a href="http://stsadm.blogspot.com/" target=_blank&gt;Gary Lapointe&lt;/a&gt; for
providing the source code for &lt;a href="http://stsadm.blogspot.com/2007/08/stsadm-commands_09.html" target=_blank&gt;his
STSADM extensions&lt;/a&gt;.&amp;nbsp; It served as a great starting place for me and decreased
the ramp-up time for creating my own custom STSADM commands tremendously.
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.codeplex.com/ajaxifymoss"&gt;View CodePlex site to download STSADM
extensions for ASP.NET AJAX&lt;/a&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://blog.richfinn.net/blog/aggbug.ashx?id=84906cb2-cc3c-4db8-a7b2-a8a77cd11645" /&gt;</description>
      <comments>http://blog.richfinn.net/blog/CommentView,guid,84906cb2-cc3c-4db8-a7b2-a8a77cd11645.aspx</comments>
      <category>Development</category>
      <category>Microsoft Office SharePoint Server</category>
    </item>
    <item>
      <trackback:ping>http://blog.richfinn.net/blog/Trackback.aspx?guid=78838983-d528-4336-9168-8c92b431119f</trackback:ping>
      <pingback:server>http://blog.richfinn.net/blog/pingback.aspx</pingback:server>
      <pingback:target>http://blog.richfinn.net/blog/PermaLink,guid,78838983-d528-4336-9168-8c92b431119f.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://blog.richfinn.net/blog/CommentView,guid,78838983-d528-4336-9168-8c92b431119f.aspx</wfw:comment>
      <wfw:commentRss>http://blog.richfinn.net/blog/SyndicationService.asmx/GetEntryCommentsRss?guid=78838983-d528-4336-9168-8c92b431119f</wfw:commentRss>
      <slash:comments>1</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <strong>
            <font color="#ff0000">&lt;update date="6/19/08"&gt;</font>
            <br />
          </strong>
          <br />
Telerik has released the MOSS compatable version of the RadEditor that places all
needed files as class resource files in the _wpresource directory.  They've also
made some very nice improvements over the previous release that make extending and
customizing the editor very easy.  If you purchase and deploy the Full-Featrured
RadEditor, you get ALL of the controls in the Telerik ASP.NET AJAX control suite available
to you in MOSS.  Very nice...<br /><br /><strong><font color="#ff0000">&lt;/update&gt;</font></strong></p>
        <p>
 
</p>
        <p>
Yesterday I posted about using the new RadControls for ASP.NET AJAX in MOSS, and I
started moving the old controls in my current project over to the new ones. 
Just now, I found a problem when I was converting the RadEditor from the old to the
new.
</p>
        <p>
In the Telerik <a href="http://www.telerik.com/help/aspnet-ajax/gettingstarted.html" target="_blank">online
documentation for getting started with the RadEditor</a>, they say that in a standard
ASP.NET AJAX application, you need to utilize the App_GlobalResources and App_Data
ASP.NET folders in order to use the RadEditor.
</p>
        <p>
That's not any different for MOSS.
</p>
        <p>
In the root of your SharePoint Web Application (\Inetpub\wwwroot\wss\VirtualDirectories\YourWebApp)
create a folder named App_Data.  Drop in the RadSpell folder from the App_Data
folder of the RadControls install directory (C:\Program Files\Telerik\RadControls
for ASPNET AJAX Q1 2008).  Then, drop the RESX files from the App_GlobalResources
directory located at the Telerik install root into the already present App_GlobalResources
directory in your SharePoint Web Application root.
</p>
        <p>
I think there's probably a better a way to do this using a Solution, but I'll worry
about that later.  Not sure if we can deploy into those folders via a WSP - I
don't think so.  I know there's a public property on the RadEditor that allows
you to point to where the RadSpell directory is, but can't find anything for the RESX
files.
</p>
        <p>
Also, make sure you add the following line to the HttpHandlers section of your web
config file, or else, spellcheck won't work:<br /><font color="#0000ff">&lt;</font><font color="maroon">add</font><font color="red">verb</font><font color="black">=</font><font color="blue">"*"</font><font color="red">validate</font><font color="black">=</font><font color="blue">"false"</font><font color="red">path</font><font color="black">=</font><font color="blue">"Telerik.Web.UI.SpellCheckHandler.axd"</font><font color="red">type</font><font color="black">=</font><font color="blue">"Telerik.Web.UI.SpellCheckHandler,
Telerik.Web.UI"/&gt;</font></p>
        <p>
Anyway, here's a screen shot of the unskinned and unmodified RadEditor running in
my local MOSS environment.  This is not tied into a publishing placeholder, but
that's not what I'm using it for right now...
</p>
        <p>
          <a href="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/HowdoIgett.NETAJAXPrometheustoworkinMOSS_DDB2/image_2.png">
            <img style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height="615" alt="image" src="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/HowdoIgett.NETAJAXPrometheustoworkinMOSS_DDB2/image_thumb.png" width="745" border="0" />
          </a>
        </p>
        <img width="0" height="0" src="http://blog.richfinn.net/blog/aggbug.ashx?id=78838983-d528-4336-9168-8c92b431119f" />
      </body>
      <title>How do I get the RadEditor for ASP.NET AJAX (Prometheus) to work in MOSS?</title>
      <guid isPermaLink="false">http://blog.richfinn.net/blog/PermaLink,guid,78838983-d528-4336-9168-8c92b431119f.aspx</guid>
      <link>http://blog.richfinn.net/blog/2008/05/08/HowDoIGetTheRadEditorForASPNETAJAXPrometheusToWorkInMOSS.aspx</link>
      <pubDate>Thu, 08 May 2008 21:45:56 GMT</pubDate>
      <description>&lt;p&gt;
&lt;strong&gt;&lt;font color=#ff0000&gt;&amp;lt;update date="6/19/08"&amp;gt;&lt;/font&gt;
&lt;br&gt;
&lt;/strong&gt;
&lt;br&gt;
Telerik has released the MOSS compatable version of the RadEditor that places all
needed files as class resource files in the _wpresource directory.&amp;nbsp; They've also
made some very nice improvements over the previous release that make extending and
customizing the editor very easy.&amp;nbsp; If you&amp;nbsp;purchase and deploy the Full-Featrured
RadEditor, you get ALL of the controls in the Telerik ASP.NET AJAX control suite available
to you in MOSS.&amp;nbsp; Very nice...&lt;br&gt;
&lt;br&gt;
&lt;strong&gt;&lt;font color=#ff0000&gt;&amp;lt;/update&amp;gt;&lt;/font&gt;&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
Yesterday I posted about using the new RadControls for ASP.NET AJAX in MOSS, and I
started moving the old controls in my current project over to the new ones.&amp;nbsp;
Just now, I found a problem when I was converting the RadEditor from the old to the
new.
&lt;/p&gt;
&lt;p&gt;
In the Telerik &lt;a href="http://www.telerik.com/help/aspnet-ajax/gettingstarted.html" target=_blank&gt;online
documentation for getting started with the RadEditor&lt;/a&gt;, they say that in a standard
ASP.NET AJAX application, you need to utilize the App_GlobalResources and App_Data
ASP.NET folders in order to use the RadEditor.
&lt;/p&gt;
&lt;p&gt;
That's not any different for MOSS.
&lt;/p&gt;
&lt;p&gt;
In the root of your SharePoint Web Application (\Inetpub\wwwroot\wss\VirtualDirectories\YourWebApp)
create a folder named App_Data.&amp;nbsp; Drop in the RadSpell folder from the App_Data
folder of the RadControls install directory (C:\Program Files\Telerik\RadControls
for ASPNET AJAX Q1 2008).&amp;nbsp; Then, drop the RESX files from the App_GlobalResources
directory located at the Telerik install root into the already present App_GlobalResources
directory in your SharePoint Web Application root.
&lt;/p&gt;
&lt;p&gt;
I think there's probably a better a way to do this using a Solution, but I'll worry
about that later.&amp;nbsp; Not sure if we can deploy into those folders via a WSP - I
don't think so.&amp;nbsp; I know there's a public property on the RadEditor that allows
you to point to where the RadSpell directory is, but can't find anything for the RESX
files.
&lt;/p&gt;
&lt;p&gt;
Also, make sure you add the following line to the HttpHandlers section of your web
config file, or else, spellcheck won't work:&lt;br&gt;
&lt;font color=#0000ff&gt;&amp;lt;&lt;/font&gt;&lt;font color=maroon&gt;add&lt;/font&gt; &lt;font color=red&gt;verb&lt;/font&gt;&lt;font color=black&gt;=&lt;/font&gt;&lt;font color=blue&gt;"*"&lt;/font&gt; &lt;font color=red&gt;validate&lt;/font&gt;&lt;font color=black&gt;=&lt;/font&gt;&lt;font color=blue&gt;"false"&lt;/font&gt; &lt;font color=red&gt;path&lt;/font&gt;&lt;font color=black&gt;=&lt;/font&gt;&lt;font color=blue&gt;"Telerik.Web.UI.SpellCheckHandler.axd"&lt;/font&gt; &lt;font color=red&gt;type&lt;/font&gt;&lt;font color=black&gt;=&lt;/font&gt;&lt;font color=blue&gt;"Telerik.Web.UI.SpellCheckHandler,
Telerik.Web.UI"/&amp;gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
Anyway, here's a screen shot of the unskinned and unmodified RadEditor running in
my local MOSS environment.&amp;nbsp; This is not tied into a publishing placeholder, but
that's not what I'm using it for right now...
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/HowdoIgett.NETAJAXPrometheustoworkinMOSS_DDB2/image_2.png"&gt;&lt;img style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height=615 alt=image src="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/HowdoIgett.NETAJAXPrometheustoworkinMOSS_DDB2/image_thumb.png" width=745 border=0&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://blog.richfinn.net/blog/aggbug.ashx?id=78838983-d528-4336-9168-8c92b431119f" /&gt;</description>
      <comments>http://blog.richfinn.net/blog/CommentView,guid,78838983-d528-4336-9168-8c92b431119f.aspx</comments>
      <category>Development</category>
      <category>Microsoft Office SharePoint Server</category>
      <category>Telerik</category>
    </item>
    <item>
      <trackback:ping>http://blog.richfinn.net/blog/Trackback.aspx?guid=cb6e174c-c7a1-43fb-ada3-dc596caeaff9</trackback:ping>
      <pingback:server>http://blog.richfinn.net/blog/pingback.aspx</pingback:server>
      <pingback:target>http://blog.richfinn.net/blog/PermaLink,guid,cb6e174c-c7a1-43fb-ada3-dc596caeaff9.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://blog.richfinn.net/blog/CommentView,guid,cb6e174c-c7a1-43fb-ada3-dc596caeaff9.aspx</wfw:comment>
      <wfw:commentRss>http://blog.richfinn.net/blog/SyndicationService.asmx/GetEntryCommentsRss?guid=cb6e174c-c7a1-43fb-ada3-dc596caeaff9</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I've been a huge proponent of <a href="http://www.telerik.com" target="_blank">Telerik</a> because
of their very impressive controls, support, and documentation - let alone for the
fact they are very easy to use.  Now that I've been working with SharePoint 2007
for a few years, I've found that Telerik's controls fit very nicely into MOSS. 
Andrew Connell even created an <a href="http://www.telerik.com/documents/MOSS_whitepaper.pdf" target="_blank">integration
whitepaper</a> and some <a href="http://www.telerik.com/documents/moss_utilities.zip" target="_blank">nice
utility EXEs</a> to help package the individual controls into WSPs to deploy them
into MOSS.
</p>
        <p>
Then, on April 15 of this year, Telerik released version 2008.1 of their new <a href="http://www.telerik.com/products/aspnet-ajax/overview.aspx" target="_blank">RadControls
Suite for ASP.NET AJAX</a>, formerly named 'Prometheus'.  I purchased my upgrade
from the old RadControl suite to the Prometheus controls yesterday, and there was
something that I noticed immediately which frightened me a little.  There's only
one assembly - Telerik.Web.UI.ddl - and nowhere that I could see on the Telerik site
that allowed me to get an individual control.
</p>
        <p>
Uh oh.  
</p>
        <p>
How do I get these amazing controls into SharePoint and start benefiting from that
ASP.NET AJAX goodness?  Do I package the whole thing into a WSP? I hope not!
That'll be a huge WSP file with all those skins getting packaged up!
</p>
        <p>
I was worried, and started thinking that I was going to be stuck with a legacy version
of some great controls, being forced to sit  here watching new versions go sailing
past every three months.  No way!!!
</p>
        <p>
I figured that there had to be a way, and if it took a massive WSP, so be it, so I
started poking around the new control suite to see how it ticked.  There's no
RadControls directory, so AC's walk-through documentation won't work.
</p>
        <p>
I tested the RadSlider locally, and I asked myself, where do the images come from
in the control?
</p>
        <p>
          <a href="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/IntegratingNewestT.NETAJAXintoSharePoint_EAD2/image_4.png">
            <img style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height="111" alt="image" src="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/IntegratingNewestT.NETAJAXintoSharePoint_EAD2/image_thumb_1.png" width="241" border="0" />
          </a>
        </p>
        <p>
I got out my trusty IE Dev Toolbar and took a peak.  I liked what I saw.
</p>
        <p>
          <a href="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/IntegratingNewestT.NETAJAXintoSharePoint_EAD2/image_8.png">
            <img style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height="58" alt="image" src="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/IntegratingNewestT.NETAJAXintoSharePoint_EAD2/image_thumb_3.png" width="315" border="0" />
          </a>
        </p>
        <p>
WebResource.axd!
</p>
        <p>
Now, I don't care if this image is an embedded resource file or not.  It's not
a direct reference to an image, and that's what matters.  What happens if a skin
is applied? Where's the image then?
</p>
        <p>
Office2007 skin:<br /><a href="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/IntegratingNewestT.NETAJAXintoSharePoint_EAD2/image_10.png"><img style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height="27" alt="image" src="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/IntegratingNewestT.NETAJAXintoSharePoint_EAD2/image_thumb_4.png" width="215" border="0" /></a></p>
        <p>
IE Dev Toolbar:<br /><a href="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/IntegratingNewestT.NETAJAXintoSharePoint_EAD2/image_12.png"><img style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height="52" alt="image" src="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/IntegratingNewestT.NETAJAXintoSharePoint_EAD2/image_thumb_5.png" width="304" border="0" /></a></p>
        <p>
Still a WebResource.axd. Excellent!
</p>
        <p>
So - here's the deal.  Install the entire RadControls EXE which you get via your
Telerik account on your SharePoint server.  Deploy the Telerik.Web.UI.dll to
your SharePoint application's bin, and add the following line to the SafeControls
block in the web.config
</p>
        <p>
          <a href="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/IntegratingNewestT.NETAJAXintoSharePoint_EAD2/image_14.png">
            <img style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height="20" alt="image" src="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/IntegratingNewestT.NETAJAXintoSharePoint_EAD2/image_thumb_6.png" width="658" border="0" />
          </a>
        </p>
        <p>
That's it...
</p>
        <p>
Then, you can use any control in the entire suite just by adding the following Register
tag to the page where you're using it<br /><a href="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/IntegratingNewestT.NETAJAXintoSharePoint_EAD2/image_16.png"><img style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height="29" alt="image" src="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/IntegratingNewestT.NETAJAXintoSharePoint_EAD2/image_thumb_7.png" width="631" border="0" /></a></p>
        <p>
No more individual control references anywhere! Sweet!
</p>
        <p>
For example - the RadTreeView control:<br /><a href="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/IntegratingNewestT.NETAJAXintoSharePoint_EAD2/image_18.png"><img style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height="34" alt="image" src="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/IntegratingNewestT.NETAJAXintoSharePoint_EAD2/image_thumb_8.png" width="750" border="0" /></a></p>
        <p>
You can even deploy this inside your custom WSP by using the various Visual Studio
project templates available on CodePlex.  I know of three that support deploying
other assemblies, so finding them shouldn't be hard.  <a href="http://www.codeplex.com/wspprojecttemplate" target="_blank">I'm
partial to this one</a>, and I know <a href="http://www.codeplex.com/stsdev" target="_blank">stsdev</a> is
really nice, as well.  You can even reference the Telerik control assembly server-side,
too.  Just make sure you set the CopyLocal property of the reference to False.
</p>
        <p>
You won't get IntelliSense for the controls, but as far as MOSS dev goes - what else
is new, right?  There's plenty of documentation on Telerik's site to help with
the control properties and client-side API.
</p>
        <p>
Here's the new RadSlider with the Office2007 skin running in one of my MOSS environment:<br /><a href="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/IntegratingNewestT.NETAJAXintoSharePoint_EAD2/image_20.png"><img style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height="230" alt="image" src="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/IntegratingNewestT.NETAJAXintoSharePoint_EAD2/image_thumb_9.png" width="483" border="0" /></a></p>
        <p>
I've started moving over all of the controls in my current project from the old version
of the suite to the new version, and there's been some minor changes, but nothing
of a pain at all.  The changes I have seen have been good ones, so it's been
worth it so far.  Besides, these controls ROCK!  I haven't gone through
and seen which ones work and which don't, but I'm sure it'll be similar to the old
version of the suite.  I know the RadSplitter was a hassle before, will have
to try it again with the new ones.  I've even noticed some performance gains
over the old controls.
</p>
        <p>
So, if you haven't picked up on it, I highly recommend these controls.  Not only
will they completely expand your MOSS UI potential, but they will get you to install
Service Pack 1 and <a href="http://sharepoint.microsoft.com/blogs/mike/Lists/Posts/Post.aspx?ID=3" target="_blank">configure
ASP.NET AJAX in SharePoint</a> if you haven't yet.  Remember, SP1 is required
if you want to use ASP.NET AJAX, therefore, it's required to use these controls.
</p>
        <img width="0" height="0" src="http://blog.richfinn.net/blog/aggbug.ashx?id=cb6e174c-c7a1-43fb-ada3-dc596caeaff9" />
      </body>
      <title>Integrating Newest Telerik RadControls for ASP.NET AJAX into SharePoint</title>
      <guid isPermaLink="false">http://blog.richfinn.net/blog/PermaLink,guid,cb6e174c-c7a1-43fb-ada3-dc596caeaff9.aspx</guid>
      <link>http://blog.richfinn.net/blog/2008/05/07/IntegratingNewestTelerikRadControlsForASPNETAJAXIntoSharePoint.aspx</link>
      <pubDate>Wed, 07 May 2008 22:43:12 GMT</pubDate>
      <description>&lt;p&gt;
I've been a huge proponent of &lt;a href="http://www.telerik.com" target=_blank&gt;Telerik&lt;/a&gt;&amp;nbsp;because
of their very impressive controls, support, and documentation - let alone for the
fact they are very easy to use.&amp;nbsp; Now that I've been working with SharePoint 2007
for a few years, I've found that Telerik's controls fit very nicely into MOSS.&amp;nbsp;
Andrew Connell even created an &lt;a href="http://www.telerik.com/documents/MOSS_whitepaper.pdf" target=_blank&gt;integration
whitepaper&lt;/a&gt; and some &lt;a href="http://www.telerik.com/documents/moss_utilities.zip" target=_blank&gt;nice
utility EXEs&lt;/a&gt; to help package the individual controls into WSPs to deploy them
into MOSS.
&lt;/p&gt;
&lt;p&gt;
Then, on April 15 of this year, Telerik released version 2008.1 of their new &lt;a href="http://www.telerik.com/products/aspnet-ajax/overview.aspx" target=_blank&gt;RadControls
Suite for ASP.NET AJAX&lt;/a&gt;, formerly named 'Prometheus'.&amp;nbsp; I purchased my upgrade
from the old RadControl suite to the Prometheus controls yesterday, and there was
something that I noticed immediately which frightened me a little.&amp;nbsp; There's only
one assembly - Telerik.Web.UI.ddl - and nowhere that I could see on the Telerik site
that allowed me to get an individual control.
&lt;/p&gt;
&lt;p&gt;
Uh oh.&amp;nbsp; 
&lt;/p&gt;
&lt;p&gt;
How do I get these amazing controls into SharePoint and start benefiting from that
ASP.NET AJAX goodness?&amp;nbsp; Do I package the whole thing into a WSP? I hope not!
That'll be a huge WSP file with all those skins getting packaged up!
&lt;/p&gt;
&lt;p&gt;
I was worried, and started thinking that I was going to be stuck with a legacy version
of some great controls, being forced to sit&amp;nbsp; here watching new versions go sailing
past every three months.&amp;nbsp; No way!!!
&lt;/p&gt;
&lt;p&gt;
I figured that there had to be a way, and if it took a massive WSP, so be it, so I
started poking around the new control suite to see how it ticked.&amp;nbsp; There's no
RadControls directory, so AC's walk-through documentation won't work.
&lt;/p&gt;
&lt;p&gt;
I tested the RadSlider locally, and I asked myself, where do the images come from
in the control?
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/IntegratingNewestT.NETAJAXintoSharePoint_EAD2/image_4.png"&gt;&lt;img style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height=111 alt=image src="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/IntegratingNewestT.NETAJAXintoSharePoint_EAD2/image_thumb_1.png" width=241 border=0&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
I got out my trusty IE Dev Toolbar and took a peak.&amp;nbsp; I liked what I saw.
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/IntegratingNewestT.NETAJAXintoSharePoint_EAD2/image_8.png"&gt;&lt;img style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height=58 alt=image src="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/IntegratingNewestT.NETAJAXintoSharePoint_EAD2/image_thumb_3.png" width=315 border=0&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
WebResource.axd!
&lt;/p&gt;
&lt;p&gt;
Now, I don't care if this image is an embedded resource file or not.&amp;nbsp; It's not
a direct reference to an image, and that's what matters.&amp;nbsp; What happens if a skin
is applied? Where's the image then?
&lt;/p&gt;
&lt;p&gt;
Office2007 skin:&lt;br&gt;
&lt;a href="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/IntegratingNewestT.NETAJAXintoSharePoint_EAD2/image_10.png"&gt;&lt;img style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height=27 alt=image src="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/IntegratingNewestT.NETAJAXintoSharePoint_EAD2/image_thumb_4.png" width=215 border=0&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
IE Dev Toolbar:&lt;br&gt;
&lt;a href="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/IntegratingNewestT.NETAJAXintoSharePoint_EAD2/image_12.png"&gt;&lt;img style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height=52 alt=image src="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/IntegratingNewestT.NETAJAXintoSharePoint_EAD2/image_thumb_5.png" width=304 border=0&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
Still a WebResource.axd. Excellent!
&lt;/p&gt;
&lt;p&gt;
So - here's the deal.&amp;nbsp; Install the entire RadControls EXE which you get via your
Telerik account on your SharePoint server.&amp;nbsp; Deploy the Telerik.Web.UI.dll to
your SharePoint application's bin, and add the following line to the SafeControls
block in the web.config
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/IntegratingNewestT.NETAJAXintoSharePoint_EAD2/image_14.png"&gt;&lt;img style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height=20 alt=image src="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/IntegratingNewestT.NETAJAXintoSharePoint_EAD2/image_thumb_6.png" width=658 border=0&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
That's it...
&lt;/p&gt;
&lt;p&gt;
Then, you can use any control in the entire suite just by adding the following Register
tag to the page where you're using it&lt;br&gt;
&lt;a href="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/IntegratingNewestT.NETAJAXintoSharePoint_EAD2/image_16.png"&gt;&lt;img style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height=29 alt=image src="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/IntegratingNewestT.NETAJAXintoSharePoint_EAD2/image_thumb_7.png" width=631 border=0&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
No more individual control references anywhere! Sweet!
&lt;/p&gt;
&lt;p&gt;
For example - the RadTreeView control:&lt;br&gt;
&lt;a href="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/IntegratingNewestT.NETAJAXintoSharePoint_EAD2/image_18.png"&gt;&lt;img style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height=34 alt=image src="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/IntegratingNewestT.NETAJAXintoSharePoint_EAD2/image_thumb_8.png" width=750 border=0&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
You can even deploy this inside your custom WSP by using the various Visual Studio
project templates available on CodePlex.&amp;nbsp; I know of three that support deploying
other assemblies, so finding them shouldn't be hard.&amp;nbsp; &lt;a href="http://www.codeplex.com/wspprojecttemplate" target=_blank&gt;I'm
partial to this one&lt;/a&gt;, and I know &lt;a href="http://www.codeplex.com/stsdev" target=_blank&gt;stsdev&lt;/a&gt; is
really nice, as well.&amp;nbsp; You can even reference the Telerik control assembly server-side,
too.&amp;nbsp; Just make sure you set the CopyLocal property of the reference to False.
&lt;/p&gt;
&lt;p&gt;
You won't get IntelliSense for the controls, but as far as MOSS dev goes - what else
is new, right?&amp;nbsp; There's plenty of documentation on Telerik's site to help with
the control properties and client-side API.
&lt;/p&gt;
&lt;p&gt;
Here's the new RadSlider with the Office2007 skin running in one of my MOSS environment:&lt;br&gt;
&lt;a href="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/IntegratingNewestT.NETAJAXintoSharePoint_EAD2/image_20.png"&gt;&lt;img style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height=230 alt=image src="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/IntegratingNewestT.NETAJAXintoSharePoint_EAD2/image_thumb_9.png" width=483 border=0&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
I've started moving over all of the controls in my current project from the old version
of the suite to the new version, and there's been some minor changes, but nothing
of a pain at all.&amp;nbsp; The changes I have seen have been good ones, so it's been
worth it so far.&amp;nbsp; Besides, these controls ROCK!&amp;nbsp; I haven't gone through
and seen which ones work and which don't, but I'm sure it'll be similar to the old
version of the suite.&amp;nbsp; I know the RadSplitter was a hassle before, will have
to try it again with the new ones.&amp;nbsp; I've even noticed some performance gains
over the old controls.
&lt;/p&gt;
&lt;p&gt;
So, if you haven't picked up on it, I highly recommend these controls.&amp;nbsp; Not only
will they completely expand your MOSS UI potential, but they will get you to install
Service Pack 1 and &lt;a href="http://sharepoint.microsoft.com/blogs/mike/Lists/Posts/Post.aspx?ID=3" target=_blank&gt;configure
ASP.NET AJAX in SharePoint&lt;/a&gt; if you haven't yet.&amp;nbsp; Remember, SP1 is required
if you want to use ASP.NET AJAX, therefore, it's required to use these controls.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://blog.richfinn.net/blog/aggbug.ashx?id=cb6e174c-c7a1-43fb-ada3-dc596caeaff9" /&gt;</description>
      <comments>http://blog.richfinn.net/blog/CommentView,guid,cb6e174c-c7a1-43fb-ada3-dc596caeaff9.aspx</comments>
      <category>Development</category>
      <category>Microsoft Office SharePoint Server</category>
      <category>Telerik</category>
    </item>
    <item>
      <trackback:ping>http://blog.richfinn.net/blog/Trackback.aspx?guid=4cff5d82-1e1b-4fe1-a6df-a75b2f3ee71c</trackback:ping>
      <pingback:server>http://blog.richfinn.net/blog/pingback.aspx</pingback:server>
      <pingback:target>http://blog.richfinn.net/blog/PermaLink,guid,4cff5d82-1e1b-4fe1-a6df-a75b2f3ee71c.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://blog.richfinn.net/blog/CommentView,guid,4cff5d82-1e1b-4fe1-a6df-a75b2f3ee71c.aspx</wfw:comment>
      <wfw:commentRss>http://blog.richfinn.net/blog/SyndicationService.asmx/GetEntryCommentsRss?guid=4cff5d82-1e1b-4fe1-a6df-a75b2f3ee71c</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Having spent a great deal of time developing Microsoft Content Management Server 2002
solutions, I've found there's a bunch of stuff I miss from the MCMS API.  The
single thing I miss the most:
</p>
        <pre style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none">CmsContext.Searches.GetByGuid(<span style="COLOR: #0000ff">string</span>) <span style="COLOR: #0000ff">as</span> HierarchyItem;</pre>
        <p>
Being able to get any object - Channel, Template, Posting, Resource - by just it's
guid was huge.  Even cooler was that you could grab an object out of anywhere
in the hierarchy/taxonomy.  In SharePoint, you have to know the Web, List, and
Item guid to find anything.  This one method in MCMS allowed a huge number of
possibilities for custom dev with very limited coding time.
</p>
        <p>
Another thing I miss from MCMS is the functionality of Connected Postings/Templates
and an API that could CRUD them without hardly any effort.  I know Variations
in SharePoint comes close, but IMO, it just doesn't seem to be at the same level and
simplicity of MCMS.  Also, there's very little documentation around any of the
Variation related objects because they've all been marked as internal.
</p>
        <p>
Luckily, <a href="http://www.sharepointblog.nl/">Michiel Lankamp</a> figured this
out - a long time ago - using Reflector <font size="1">(duh)</font> and exposed that
yes, <a href="http://blog.richfinn.net/blog/2007/09/25/RelateToSharePointAsADatabaseTheTwoLineUpPrettyWell.aspx" target="_blank">everything
in SharePoint is a list</a><font size="1">(thanks Matt)</font>. As Michiel points
out, there's two variation lists. One called VariationSettings and one called VariationLabels
who's guids are stored as Properties on the root web of the site collection.
</p>
        <p>
Once you get the lists, how do you create the hierarchy? <a href="http://www.sharepointblog.nl/post/2007/10/Enable-variations-programmatically.aspx" target="_blank">Check
out Michiel's post to see how</a>. Pretty clever...
</p>
        <p>
I haven't tried this, and based on the four comments, not many other people have,
either.  Also looks like it could be buggy.
</p>
        <p>
          <a href="http://www.sharepointblog.nl/post/2007/10/Enable-variations-programmatically.aspx" target="_blank">Enable
variations programmatically - Michiel Lankamp</a>
          <br />
        </p>
        <img width="0" height="0" src="http://blog.richfinn.net/blog/aggbug.ashx?id=4cff5d82-1e1b-4fe1-a6df-a75b2f3ee71c" />
      </body>
      <title>Programmatically Manipulating Variations</title>
      <guid isPermaLink="false">http://blog.richfinn.net/blog/PermaLink,guid,4cff5d82-1e1b-4fe1-a6df-a75b2f3ee71c.aspx</guid>
      <link>http://blog.richfinn.net/blog/2008/04/29/ProgrammaticallyManipulatingVariations.aspx</link>
      <pubDate>Tue, 29 Apr 2008 05:32:57 GMT</pubDate>
      <description>&lt;p&gt;
Having spent a great deal of time developing Microsoft Content Management Server 2002
solutions, I've found there's a bunch of stuff I miss from the MCMS API.&amp;nbsp; The
single thing I miss the most:
&lt;/p&gt;
&lt;pre style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none"&gt;CmsContext.Searches.GetByGuid(&lt;span style="COLOR: #0000ff"&gt;string&lt;/span&gt;) &lt;span style="COLOR: #0000ff"&gt;as&lt;/span&gt; HierarchyItem;&lt;/pre&gt;
&lt;p&gt;
Being able to get any object - Channel, Template, Posting, Resource - by just it's
guid was huge.&amp;nbsp; Even cooler was that you could grab an object out of anywhere
in the hierarchy/taxonomy.&amp;nbsp; In SharePoint, you have to know the Web, List, and
Item guid to find anything.&amp;nbsp; This one method in MCMS allowed a huge number of
possibilities for custom dev with very limited coding time.
&lt;/p&gt;
&lt;p&gt;
Another thing I miss from MCMS is the functionality of Connected Postings/Templates
and an API that could CRUD them without hardly any effort.&amp;nbsp; I know Variations
in SharePoint comes close, but IMO, it just doesn't seem to be at the same level and
simplicity of MCMS.&amp;nbsp; Also, there's very little documentation around any of the
Variation related objects because they've all been marked as internal.
&lt;/p&gt;
&lt;p&gt;
Luckily, &lt;a href="http://www.sharepointblog.nl/"&gt;Michiel Lankamp&lt;/a&gt; figured this
out - a long time ago - using Reflector &lt;font size=1&gt;(duh)&lt;/font&gt; and exposed that
yes, &lt;a href="http://blog.richfinn.net/blog/2007/09/25/RelateToSharePointAsADatabaseTheTwoLineUpPrettyWell.aspx" target=_blank&gt;everything
in SharePoint is a list&lt;/a&gt; &lt;font size=1&gt;(thanks Matt)&lt;/font&gt;. As Michiel points out,
there's two variation lists. One called VariationSettings and one called VariationLabels
who's guids are stored as Properties on the root web of the site collection.
&lt;/p&gt;
&lt;p&gt;
Once you get the lists, how do you create the hierarchy? &lt;a href="http://www.sharepointblog.nl/post/2007/10/Enable-variations-programmatically.aspx" target=_blank&gt;Check
out Michiel's post to see how&lt;/a&gt;. Pretty clever...
&lt;/p&gt;
&lt;p&gt;
I haven't tried this, and based on the four comments, not many other people have,
either.&amp;nbsp; Also looks like it could be buggy.
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.sharepointblog.nl/post/2007/10/Enable-variations-programmatically.aspx" target=_blank&gt;Enable
variations programmatically - Michiel Lankamp&lt;/a&gt;
&lt;br&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://blog.richfinn.net/blog/aggbug.ashx?id=4cff5d82-1e1b-4fe1-a6df-a75b2f3ee71c" /&gt;</description>
      <comments>http://blog.richfinn.net/blog/CommentView,guid,4cff5d82-1e1b-4fe1-a6df-a75b2f3ee71c.aspx</comments>
      <category>Development</category>
      <category>Microsoft Office SharePoint Server</category>
    </item>
    <item>
      <trackback:ping>http://blog.richfinn.net/blog/Trackback.aspx?guid=efd4d366-58c1-488a-b318-5fabde4648b7</trackback:ping>
      <pingback:server>http://blog.richfinn.net/blog/pingback.aspx</pingback:server>
      <pingback:target>http://blog.richfinn.net/blog/PermaLink,guid,efd4d366-58c1-488a-b318-5fabde4648b7.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://blog.richfinn.net/blog/CommentView,guid,efd4d366-58c1-488a-b318-5fabde4648b7.aspx</wfw:comment>
      <wfw:commentRss>http://blog.richfinn.net/blog/SyndicationService.asmx/GetEntryCommentsRss?guid=efd4d366-58c1-488a-b318-5fabde4648b7</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
When creating a WSP in WSSv3, the common development practice is to create a project
in Visual Studio using the Class Library project template.  The problem with
this is that none of the Workflow item templates are present when you try and add
a new item, so how can you add a Workflow without having a one-off Visual Studio project
just for your Workflow Feature?
</p>
        <p>
The answer is that you need to make some changes to the project file in Visual Studio
to make it happen.  The project file (<em>YourProject.csproj</em> - for example)
is the file which tells the IDE what files, references, folders, etc. are present
so that when the project is built, MSBuild knows how to compile the assembly correctly.
</p>
        <p>
The steps I'll walk you through are intended for Visual Studio 2005.  You need
to make sure you have the latest version of the <a href="http://www.microsoft.com/downloads/details.aspx?familyid=6D94E307-67D9-41AC-B2D6-0074D6286FA9&amp;displaylang=en" target="_blank">Office
Server SDK</a> available from MSDN.  The steps are pretty much identical for
Visual Studio 2008, you just need to make sure you change the targeted version of
the .NET Framework to be version 3.0.
</p>
        <p>
First thing - if you have the project under source control, you want to make sure
the project file is checked out or else you won't be able to edit it.
</p>
        <p>
Now, you want to unload the project in the IDE.  To do this, right-click the
project and choose 'Unload Project'
</p>
        <p>
          <a href="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/HowtoconfigureWorkflowinaclasslibrarypro_B655/image_10.png">
            <img style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height="393" alt="image" src="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/HowtoconfigureWorkflowinaclasslibrarypro_B655/image_thumb_4.png" width="233" border="0" />
          </a>
        </p>
        <p>
Once the project has been unloaded, right-click the project again and choose 'Edit
YOURPROJECT.csproj'  This will open the project file for editing in Visual Studio.
</p>
        <p>
          <a href="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/HowtoconfigureWorkflowinaclasslibrarypro_B655/image_12.png">
            <img style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height="217" alt="image" src="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/HowtoconfigureWorkflowinaclasslibrarypro_B655/image_thumb_5.png" width="273" border="0" />
          </a>
        </p>
        <p>
Locate the first PropertyGroup in the file at the top, and paste in the following
code
</p>
        <div style="BORDER-RIGHT: gray 1px solid; PADDING-RIGHT: 4px; BORDER-TOP: gray 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 8pt; PADDING-BOTTOM: 4px; MARGIN: 20px 0px 10px; OVERFLOW: auto; BORDER-LEFT: gray 1px solid; WIDTH: 97.5%; CURSOR: text; MAX-HEIGHT: 200px; LINE-HEIGHT: 12pt; PADDING-TOP: 4px; BORDER-BOTTOM: gray 1px solid; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BACKGROUND-COLOR: #f4f4f4">
          <pre style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none">
            <span style="COLOR: #0000ff">&lt;</span>
            <span style="COLOR: #800000">ProjectTypeGuids</span>
            <span style="COLOR: #0000ff">&gt;</span>{14822709-B5A1-4724-98CA-57A101D1B079};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}<span style="COLOR: #0000ff">&lt;/</span><span style="COLOR: #800000">ProjectTypeGuids</span><span style="COLOR: #0000ff">&gt;</span></pre>
        </div>
        <p>
as shown below
</p>
        <p>
          <a href="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/HowtoconfigureWorkflowinaclasslibrarypro_B655/image_14.png">
            <img style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height="251" alt="image" src="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/HowtoconfigureWorkflowinaclasslibrarypro_B655/image_thumb_6.png" width="702" border="0" />
          </a>
        </p>
        <p>
Now you need to make sure that the proper references are included
</p>
        <p>
Locate the ItemGroup in the project file with the references
</p>
        <p>
          <a href="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/HowtoconfigureWorkflowinaclasslibrarypro_B655/image_16.png">
            <img style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height="71" alt="image" src="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/HowtoconfigureWorkflowinaclasslibrarypro_B655/image_thumb_7.png" width="244" border="0" />
          </a>
        </p>
        <p>
Paste in the following references after the last reference in the ItemGroup
</p>
        <div style="BORDER-RIGHT: gray 1px solid; PADDING-RIGHT: 4px; BORDER-TOP: gray 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 8pt; PADDING-BOTTOM: 4px; MARGIN: 20px 0px 10px; OVERFLOW: auto; BORDER-LEFT: gray 1px solid; WIDTH: 97.5%; CURSOR: text; MAX-HEIGHT: 200px; LINE-HEIGHT: 12pt; PADDING-TOP: 4px; BORDER-BOTTOM: gray 1px solid; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BACKGROUND-COLOR: #f4f4f4">
          <pre style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none">
            <span style="COLOR: #0000ff">&lt;</span>
            <span style="COLOR: #800000">Reference</span>
            <span style="COLOR: #ff0000">Include</span>
            <span style="COLOR: #0000ff">="microsoft.office.workflow.tasks"</span>
            <span style="COLOR: #0000ff">/&gt;</span>
            <span style="COLOR: #0000ff">&lt;</span>
            <span style="COLOR: #800000">Reference</span>
            <span style="COLOR: #ff0000">Include</span>
            <span style="COLOR: #0000ff">="Microsoft.Sharepoint.WorkflowActions"</span>
            <span style="COLOR: #0000ff">/&gt;</span>
            <span style="COLOR: #0000ff">&lt;</span>
            <span style="COLOR: #800000">Reference</span>
            <span style="COLOR: #ff0000">Include</span>
            <span style="COLOR: #0000ff">="System.Workflow.Activities"</span>
            <span style="COLOR: #0000ff">/&gt;</span>
            <span style="COLOR: #0000ff">&lt;</span>
            <span style="COLOR: #800000">Reference</span>
            <span style="COLOR: #ff0000">Include</span>
            <span style="COLOR: #0000ff">="System.Workflow.ComponentModel"</span>
            <span style="COLOR: #0000ff">/&gt;</span>
            <span style="COLOR: #0000ff">&lt;</span>
            <span style="COLOR: #800000">Reference</span>
            <span style="COLOR: #ff0000">Include</span>
            <span style="COLOR: #0000ff">="System.Workflow.Runtime"</span>
            <span style="COLOR: #0000ff">/&gt;</span>
            <span style="COLOR: #008000">&lt;!--
you probably already have the following --&gt;</span>
            <span style="COLOR: #0000ff">&lt;</span>
            <span style="COLOR: #800000">Reference</span>
            <span style="COLOR: #ff0000">Include</span>
            <span style="COLOR: #0000ff">="Microsoft.SharePoint"</span>
            <span style="COLOR: #0000ff">/&gt;</span>
          </pre>
        </div>
        <p>
          <br />
Save the project file and reload the project
</p>
        <p>
          <a href="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/HowtoconfigureWorkflowinaclasslibrarypro_B655/image_20.png">
            <img style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height="131" alt="image" src="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/HowtoconfigureWorkflowinaclasslibrarypro_B655/image_thumb_9.png" width="244" border="0" />
          </a>
        </p>
        <p>
Now you have the Workflow item templates available, along with the support of the
Workflow designer.
</p>
        <p>
          <a href="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/HowtoconfigureWorkflowinaclasslibrarypro_B655/image_18.png">
            <img style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height="260" alt="image" src="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/HowtoconfigureWorkflowinaclasslibrarypro_B655/image_thumb_8.png" width="503" border="0" />
          </a>
        </p>
        <p>
          <a href="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/HowtoconfigureWorkflowinaclasslibrarypro_B655/image_22.png">
            <img style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height="289" alt="image" src="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/HowtoconfigureWorkflowinaclasslibrarypro_B655/image_thumb_10.png" width="570" border="0" />
          </a>
        </p>
        <p>
The final step is to change the base class for the Workflows you create.  
</p>
        <p>
If you are creating a Sequential Workflow, you need to make sure the workflow class
inherits from <em>Microsoft.SharePoint.WorkflowActions.SharePointSequentialWorkflowActivity</em>. 
This will enable the SharePoint Workflow Activities in the Visual Studio Toolbox. 
There is no base class for the SharePoint State Machine workflow other than the standard <em>System.Workflow.Activities.StateMachineWorkflowActivity.  
</em></p>
        <p>
          <a href="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/HowtoconfigureWorkflowinaclasslibrarypro_B655/image_24.png">
            <img style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height="347" alt="image" src="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/HowtoconfigureWorkflowinaclasslibrarypro_B655/image_thumb_11.png" width="151" border="0" />
          </a>
        </p>
        <p>
The one main piece of advice I have is to make sure you set the base class of the
Workflow class before you start working on it.<span style="mso-spacerun: yes">  </span>When
you change the base class, all child activities will be removed from the Workflow.<span style="mso-spacerun: yes">  </span>At
least they were removed for me!
</p>
        <p>
          <a href="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/HowtoconfigureWorkflowinaclasslibrarypro_B655/image_24.png">
          </a> 
</p>
        <img width="0" height="0" src="http://blog.richfinn.net/blog/aggbug.ashx?id=efd4d366-58c1-488a-b318-5fabde4648b7" />
      </body>
      <title>Enable Workflow development in a class library project being used to create a WSSv3 Solution</title>
      <guid isPermaLink="false">http://blog.richfinn.net/blog/PermaLink,guid,efd4d366-58c1-488a-b318-5fabde4648b7.aspx</guid>
      <link>http://blog.richfinn.net/blog/2007/12/28/EnableWorkflowDevelopmentInAClassLibraryProjectBeingUsedToCreateAWSSv3Solution.aspx</link>
      <pubDate>Fri, 28 Dec 2007 22:05:56 GMT</pubDate>
      <description>&lt;p&gt;
When creating a WSP in WSSv3, the common development practice is to create a project
in Visual Studio using the Class Library project template.&amp;nbsp; The problem with
this is that none of the Workflow item templates are present when you try and add
a new item, so how can you add a Workflow without having a one-off Visual Studio project
just for your Workflow Feature?
&lt;/p&gt;
&lt;p&gt;
The answer is that you need to make some changes to the project file in Visual Studio
to make it happen.&amp;nbsp; The project file (&lt;em&gt;YourProject.csproj&lt;/em&gt; - for example)
is the file which tells the IDE what files, references, folders, etc. are present
so that when the project is built, MSBuild knows how to compile the assembly correctly.
&lt;/p&gt;
&lt;p&gt;
The steps I'll walk you through are intended for Visual Studio 2005.&amp;nbsp; You need
to make sure you have the latest version of the &lt;a href="http://www.microsoft.com/downloads/details.aspx?familyid=6D94E307-67D9-41AC-B2D6-0074D6286FA9&amp;amp;displaylang=en" target=_blank&gt;Office
Server SDK&lt;/a&gt; available from MSDN.&amp;nbsp; The steps are pretty much identical for
Visual Studio 2008, you just need to make sure you change the targeted version of
the .NET Framework to be version 3.0.
&lt;/p&gt;
&lt;p&gt;
First thing - if you have the project under source control, you want to make sure
the project file is checked out or else you won't be able to edit it.
&lt;/p&gt;
&lt;p&gt;
Now, you want to unload the project in the IDE.&amp;nbsp; To do this, right-click the
project and choose 'Unload Project'
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/HowtoconfigureWorkflowinaclasslibrarypro_B655/image_10.png"&gt;&lt;img style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height=393 alt=image src="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/HowtoconfigureWorkflowinaclasslibrarypro_B655/image_thumb_4.png" width=233 border=0&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
Once the project has been unloaded, right-click the project again and choose 'Edit
YOURPROJECT.csproj'&amp;nbsp; This will open the project file for editing in Visual Studio.
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/HowtoconfigureWorkflowinaclasslibrarypro_B655/image_12.png"&gt;&lt;img style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height=217 alt=image src="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/HowtoconfigureWorkflowinaclasslibrarypro_B655/image_thumb_5.png" width=273 border=0&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
Locate the first PropertyGroup in the file at the top, and paste in the following
code
&lt;/p&gt;
&lt;div style="BORDER-RIGHT: gray 1px solid; PADDING-RIGHT: 4px; BORDER-TOP: gray 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 8pt; PADDING-BOTTOM: 4px; MARGIN: 20px 0px 10px; OVERFLOW: auto; BORDER-LEFT: gray 1px solid; WIDTH: 97.5%; CURSOR: text; MAX-HEIGHT: 200px; LINE-HEIGHT: 12pt; PADDING-TOP: 4px; BORDER-BOTTOM: gray 1px solid; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BACKGROUND-COLOR: #f4f4f4"&gt;&lt;pre style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none"&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #800000"&gt;ProjectTypeGuids&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;gt;&lt;/span&gt;{14822709-B5A1-4724-98CA-57A101D1B079};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}&lt;span style="COLOR: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #800000"&gt;ProjectTypeGuids&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;gt;&lt;/span&gt; &lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;
as shown below
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/HowtoconfigureWorkflowinaclasslibrarypro_B655/image_14.png"&gt;&lt;img style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height=251 alt=image src="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/HowtoconfigureWorkflowinaclasslibrarypro_B655/image_thumb_6.png" width=702 border=0&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
Now you need to make sure that the proper references are included
&lt;/p&gt;
&lt;p&gt;
Locate the ItemGroup in the project file with the references
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/HowtoconfigureWorkflowinaclasslibrarypro_B655/image_16.png"&gt;&lt;img style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height=71 alt=image src="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/HowtoconfigureWorkflowinaclasslibrarypro_B655/image_thumb_7.png" width=244 border=0&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
Paste in the following references after the last reference in the ItemGroup
&lt;/p&gt;
&lt;div style="BORDER-RIGHT: gray 1px solid; PADDING-RIGHT: 4px; BORDER-TOP: gray 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 8pt; PADDING-BOTTOM: 4px; MARGIN: 20px 0px 10px; OVERFLOW: auto; BORDER-LEFT: gray 1px solid; WIDTH: 97.5%; CURSOR: text; MAX-HEIGHT: 200px; LINE-HEIGHT: 12pt; PADDING-TOP: 4px; BORDER-BOTTOM: gray 1px solid; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BACKGROUND-COLOR: #f4f4f4"&gt;&lt;pre style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none"&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #800000"&gt;Reference&lt;/span&gt; &lt;span style="COLOR: #ff0000"&gt;Include&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;="microsoft.office.workflow.tasks"&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;/&amp;gt;&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #800000"&gt;Reference&lt;/span&gt; &lt;span style="COLOR: #ff0000"&gt;Include&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;="Microsoft.Sharepoint.WorkflowActions"&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;/&amp;gt;&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #800000"&gt;Reference&lt;/span&gt; &lt;span style="COLOR: #ff0000"&gt;Include&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;="System.Workflow.Activities"&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;/&amp;gt;&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #800000"&gt;Reference&lt;/span&gt; &lt;span style="COLOR: #ff0000"&gt;Include&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;="System.Workflow.ComponentModel"&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;/&amp;gt;&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #800000"&gt;Reference&lt;/span&gt; &lt;span style="COLOR: #ff0000"&gt;Include&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;="System.Workflow.Runtime"&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;/&amp;gt;&lt;/span&gt; &lt;span style="COLOR: #008000"&gt;&amp;lt;!--
you probably already have the following --&amp;gt;&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #800000"&gt;Reference&lt;/span&gt; &lt;span style="COLOR: #ff0000"&gt;Include&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;="Microsoft.SharePoint"&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;/&amp;gt;&lt;/span&gt; &lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;
&lt;br&gt;
Save the project file and reload the project
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/HowtoconfigureWorkflowinaclasslibrarypro_B655/image_20.png"&gt;&lt;img style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height=131 alt=image src="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/HowtoconfigureWorkflowinaclasslibrarypro_B655/image_thumb_9.png" width=244 border=0&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
Now you have the Workflow item templates available, along with the support of the
Workflow designer.
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/HowtoconfigureWorkflowinaclasslibrarypro_B655/image_18.png"&gt;&lt;img style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height=260 alt=image src="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/HowtoconfigureWorkflowinaclasslibrarypro_B655/image_thumb_8.png" width=503 border=0&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/HowtoconfigureWorkflowinaclasslibrarypro_B655/image_22.png"&gt;&lt;img style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height=289 alt=image src="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/HowtoconfigureWorkflowinaclasslibrarypro_B655/image_thumb_10.png" width=570 border=0&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
The final step is to change the base class for the Workflows you create.&amp;nbsp; 
&lt;/p&gt;
&lt;p&gt;
If you are creating a Sequential Workflow, you need to make sure the workflow class
inherits from &lt;em&gt;Microsoft.SharePoint.WorkflowActions.SharePointSequentialWorkflowActivity&lt;/em&gt;.&amp;nbsp;
This will enable the SharePoint Workflow Activities in the Visual Studio Toolbox.&amp;nbsp;
There is no base class for the SharePoint State Machine workflow other than the standard &lt;em&gt;System.Workflow.Activities.StateMachineWorkflowActivity.&amp;nbsp; 
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/HowtoconfigureWorkflowinaclasslibrarypro_B655/image_24.png"&gt;&lt;img style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height=347 alt=image src="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/HowtoconfigureWorkflowinaclasslibrarypro_B655/image_thumb_11.png" width=151 border=0&gt;&lt;/a&gt;
&lt;/p&gt;
&gt; 
&lt;p&gt;
The one main piece of advice I have is to make sure you set the base class of the
Workflow class before you start working on it.&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;When
you change the base class, all child activities will be removed from the Workflow.&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;At
least they were removed for me!
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://blog.richfinn.net/blog/content/binary/WindowsLiveWriter/HowtoconfigureWorkflowinaclasslibrarypro_B655/image_24.png"&gt;&lt;/a&gt;&amp;nbsp;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://blog.richfinn.net/blog/aggbug.ashx?id=efd4d366-58c1-488a-b318-5fabde4648b7" /&gt;</description>
      <comments>http://blog.richfinn.net/blog/CommentView,guid,efd4d366-58c1-488a-b318-5fabde4648b7.aspx</comments>
      <category>Development</category>
      <category>Microsoft Office SharePoint Server</category>
      <category>WSP Development</category>
    </item>
    <item>
      <trackback:ping>http://blog.richfinn.net/blog/Trackback.aspx?guid=ef5c964f-ad19-4bdf-855d-69a894950a93</trackback:ping>
      <pingback:server>http://blog.richfinn.net/blog/pingback.aspx</pingback:server>
      <pingback:target>http://blog.richfinn.net/blog/PermaLink,guid,ef5c964f-ad19-4bdf-855d-69a894950a93.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://blog.richfinn.net/blog/CommentView,guid,ef5c964f-ad19-4bdf-855d-69a894950a93.aspx</wfw:comment>
      <wfw:commentRss>http://blog.richfinn.net/blog/SyndicationService.asmx/GetEntryCommentsRss?guid=ef5c964f-ad19-4bdf-855d-69a894950a93</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Being Asp.Net developers, we all know we can send email from within custom code using
the virtual SMPT server running on the Web Front End server where our code is running,
but what if you want to use the same SMTP/Exchange settings you configured in Central
Administration?
</p>
        <p>
Luckily, there's a way to do so.
</p>
        <p>
I like to create an object I call <em>SPEmail</em> for encapsulation, then within
the Send method go dig for the info I need from the SPAdministrationWebApplication.Local
and it's OutboundMailServerInstance property.  Once you have these objects, the
information entered in Central Admin can be obtained and be used to set up the standard
System.Net.Mail SmtpClient and MailMessage objects.  
</p>
        <p>
No messing with the web.config file. Nice.
</p>
        <p>
Here's the code for my SPEmail object:
</p>
        <div style="BORDER-RIGHT: gray 1px solid; PADDING-RIGHT: 4px; BORDER-TOP: gray 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 8pt; PADDING-BOTTOM: 4px; MARGIN: 20px 0px 10px; OVERFLOW: auto; BORDER-LEFT: gray 1px solid; WIDTH: 97.5%; CURSOR: text; MAX-HEIGHT: 200px; LINE-HEIGHT: 12pt; PADDING-TOP: 4px; BORDER-BOTTOM: gray 1px solid; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BACKGROUND-COLOR: #f4f4f4">
          <pre style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none">
            <span style="COLOR: #0000ff">public</span>
            <span style="COLOR: #0000ff">class</span> SPEmail
{ <span style="COLOR: #cc6633">#region</span> Constructors <span style="COLOR: #0000ff">public</span> SPEmail()
{ } <span style="COLOR: #cc6633">#endregion</span><span style="COLOR: #cc6633">#region</span> Private
Members <span style="COLOR: #0000ff">string</span> _To = <span style="COLOR: #0000ff">string</span>.Empty; <span style="COLOR: #0000ff">string</span> _Subject
= <span style="COLOR: #0000ff">string</span>.Empty; <span style="COLOR: #0000ff">string</span> _Body
= <span style="COLOR: #0000ff">string</span>.Empty; <span style="COLOR: #0000ff">bool</span> _HTML
= <span style="COLOR: #0000ff">false</span>; <span style="COLOR: #cc6633">#endregion</span><span style="COLOR: #cc6633">#region</span> Public
Properties <span style="COLOR: #0000ff">public</span><span style="COLOR: #0000ff">string</span> To
{ get { <span style="COLOR: #0000ff">return</span><span style="COLOR: #0000ff">this</span>._To;
} set { <span style="COLOR: #0000ff">this</span>._To = <span style="COLOR: #0000ff">value</span>;
} } <span style="COLOR: #0000ff">public</span><span style="COLOR: #0000ff">string</span> Subject
{ get { <span style="COLOR: #0000ff">return</span><span style="COLOR: #0000ff">this</span>._Subject;
} set { <span style="COLOR: #0000ff">this</span>._Subject = <span style="COLOR: #0000ff">value</span>;
} } <span style="COLOR: #0000ff">public</span><span style="COLOR: #0000ff">string</span> Body
{ get { <span style="COLOR: #0000ff">return</span><span style="COLOR: #0000ff">this</span>._Body;
} set { <span style="COLOR: #0000ff">this</span>._Body = <span style="COLOR: #0000ff">value</span>;
} } <span style="COLOR: #0000ff">public</span><span style="COLOR: #0000ff">bool</span> IsHtml
{ get { <span style="COLOR: #0000ff">return</span><span style="COLOR: #0000ff">this</span>._HTML;
} set { <span style="COLOR: #0000ff">this</span>._HTML = <span style="COLOR: #0000ff">value</span>;
} } <span style="COLOR: #cc6633">#endregion</span><span style="COLOR: #0000ff">public</span><span style="COLOR: #0000ff">void</span> Send()
{ <span style="COLOR: #0000ff">string</span> smtp = <span style="COLOR: #0000ff">string</span>.Empty; <span style="COLOR: #0000ff">string</span> fromAddress
= <span style="COLOR: #0000ff">string</span>.Empty; <span style="COLOR: #0000ff">string</span> replyToAddress
= <span style="COLOR: #0000ff">string</span>.Empty; SPSecurity.RunWithElevatedPrivileges(<span style="COLOR: #0000ff">delegate</span>()
{ SPAdministrationWebApplication adminApp = Microsoft.SharePoint.Administration.SPAdministrationWebApplication.Local;
SPOutboundMailServiceInstance emailService = adminApp.OutboundMailServiceInstance;
smtp = emailService.Server.Address; fromAddress = adminApp.OutboundMailSenderAddress;
replyToAddress = adminApp.OutboundMailReplyToAddress; <span style="COLOR: #0000ff">if</span> (!<span style="COLOR: #0000ff">string</span>.IsNullOrEmpty(<span style="COLOR: #0000ff">this</span>.To))
{ SmtpClient mail = <span style="COLOR: #0000ff">new</span> SmtpClient(); MailMessage
message = <span style="COLOR: #0000ff">new</span> MailMessage(); message.From = <span style="COLOR: #0000ff">new</span> MailAddress(fromAddress);
message.To.Add(<span style="COLOR: #0000ff">this</span>.To); <span style="COLOR: #0000ff">if</span> (!<span style="COLOR: #0000ff">string</span>.IsNullOrEmpty(replyToAddress))
message.ReplyTo = <span style="COLOR: #0000ff">new</span> MailAddress(replyToAddress); <span style="COLOR: #0000ff">if</span> (!<span style="COLOR: #0000ff">string</span>.IsNullOrEmpty(<span style="COLOR: #0000ff">this</span>.Subject))
message.Subject = <span style="COLOR: #0000ff">this</span>.Subject; <span style="COLOR: #0000ff">if</span> (!<span style="COLOR: #0000ff">string</span>.IsNullOrEmpty(<span style="COLOR: #0000ff">this</span>.Body))
message.Body = <span style="COLOR: #0000ff">this</span>.Body; message.IsBodyHtml = <span style="COLOR: #0000ff">this</span>.IsHtml;
mail.Host = smtp; mail.Send(message); } }); } }</pre>
        </div>
        <p>
So - if you want to write your own, there you go!
</p>
        <p>
Sigh...
</p>
        <p>
After I put this together, I found that you can send email from within the SPUtility
object.  SPUtility.SendEmail() will take care of all this for you, too.  
</p>
        <img width="0" height="0" src="http://blog.richfinn.net/blog/aggbug.ashx?id=ef5c964f-ad19-4bdf-855d-69a894950a93" />
      </body>
      <title>Send email from MOSS using Outbound Email settings in Central Administration</title>
      <guid isPermaLink="false">http://blog.richfinn.net/blog/PermaLink,guid,ef5c964f-ad19-4bdf-855d-69a894950a93.aspx</guid>
      <link>http://blog.richfinn.net/blog/2007/12/14/SendEmailFromMOSSUsingOutboundEmailSettingsInCentralAdministration.aspx</link>
      <pubDate>Fri, 14 Dec 2007 19:23:43 GMT</pubDate>
      <description>&lt;p&gt;
Being Asp.Net developers, we all know we can send email from within custom code using
the virtual SMPT server running on the Web Front End server where our code is running,
but what if you want to use the same SMTP/Exchange settings you configured in Central
Administration?
&lt;/p&gt;
&lt;p&gt;
Luckily, there's a way to do so.
&lt;/p&gt;
&lt;p&gt;
I like to create an object I call &lt;em&gt;SPEmail&lt;/em&gt; for encapsulation, then within
the Send method go dig for the info I need from the SPAdministrationWebApplication.Local
and it's OutboundMailServerInstance property.&amp;nbsp; Once you have these objects, the
information entered in Central Admin can be obtained and be used to set up the standard
System.Net.Mail SmtpClient and MailMessage objects.&amp;nbsp; 
&lt;/p&gt;
&lt;p&gt;
No messing with the web.config file. Nice.
&lt;/p&gt;
&lt;p&gt;
Here's the code for my SPEmail object:
&lt;/p&gt;
&lt;div style="BORDER-RIGHT: gray 1px solid; PADDING-RIGHT: 4px; BORDER-TOP: gray 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 8pt; PADDING-BOTTOM: 4px; MARGIN: 20px 0px 10px; OVERFLOW: auto; BORDER-LEFT: gray 1px solid; WIDTH: 97.5%; CURSOR: text; MAX-HEIGHT: 200px; LINE-HEIGHT: 12pt; PADDING-TOP: 4px; BORDER-BOTTOM: gray 1px solid; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BACKGROUND-COLOR: #f4f4f4"&gt;&lt;pre style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none"&gt;&lt;span style="COLOR: #0000ff"&gt;public&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;class&lt;/span&gt; SPEmail
{ &lt;span style="COLOR: #cc6633"&gt;#region&lt;/span&gt; Constructors &lt;span style="COLOR: #0000ff"&gt;public&lt;/span&gt; SPEmail()
{ } &lt;span style="COLOR: #cc6633"&gt;#endregion&lt;/span&gt; &lt;span style="COLOR: #cc6633"&gt;#region&lt;/span&gt; Private
Members &lt;span style="COLOR: #0000ff"&gt;string&lt;/span&gt; _To = &lt;span style="COLOR: #0000ff"&gt;string&lt;/span&gt;.Empty; &lt;span style="COLOR: #0000ff"&gt;string&lt;/span&gt; _Subject
= &lt;span style="COLOR: #0000ff"&gt;string&lt;/span&gt;.Empty; &lt;span style="COLOR: #0000ff"&gt;string&lt;/span&gt; _Body
= &lt;span style="COLOR: #0000ff"&gt;string&lt;/span&gt;.Empty; &lt;span style="COLOR: #0000ff"&gt;bool&lt;/span&gt; _HTML
= &lt;span style="COLOR: #0000ff"&gt;false&lt;/span&gt;; &lt;span style="COLOR: #cc6633"&gt;#endregion&lt;/span&gt; &lt;span style="COLOR: #cc6633"&gt;#region&lt;/span&gt; Public
Properties &lt;span style="COLOR: #0000ff"&gt;public&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;string&lt;/span&gt; To
{ get { &lt;span style="COLOR: #0000ff"&gt;return&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;this&lt;/span&gt;._To;
} set { &lt;span style="COLOR: #0000ff"&gt;this&lt;/span&gt;._To = &lt;span style="COLOR: #0000ff"&gt;value&lt;/span&gt;;
} } &lt;span style="COLOR: #0000ff"&gt;public&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;string&lt;/span&gt; Subject
{ get { &lt;span style="COLOR: #0000ff"&gt;return&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;this&lt;/span&gt;._Subject;
} set { &lt;span style="COLOR: #0000ff"&gt;this&lt;/span&gt;._Subject = &lt;span style="COLOR: #0000ff"&gt;value&lt;/span&gt;;
} } &lt;span style="COLOR: #0000ff"&gt;public&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;string&lt;/span&gt; Body
{ get { &lt;span style="COLOR: #0000ff"&gt;return&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;this&lt;/span&gt;._Body;
} set { &lt;span style="COLOR: #0000ff"&gt;this&lt;/span&gt;._Body = &lt;span style="COLOR: #0000ff"&gt;value&lt;/span&gt;;
} } &lt;span style="COLOR: #0000ff"&gt;public&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;bool&lt;/span&gt; IsHtml
{ get { &lt;span style="COLOR: #0000ff"&gt;return&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;this&lt;/span&gt;._HTML;
} set { &lt;span style="COLOR: #0000ff"&gt;this&lt;/span&gt;._HTML = &lt;span style="COLOR: #0000ff"&gt;value&lt;/span&gt;;
} } &lt;span style="COLOR: #cc6633"&gt;#endregion&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;public&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;void&lt;/span&gt; Send()
{ &lt;span style="COLOR: #0000ff"&gt;string&lt;/span&gt; smtp = &lt;span style="COLOR: #0000ff"&gt;string&lt;/span&gt;.Empty; &lt;span style="COLOR: #0000ff"&gt;string&lt;/span&gt; fromAddress
= &lt;span style="COLOR: #0000ff"&gt;string&lt;/span&gt;.Empty; &lt;span style="COLOR: #0000ff"&gt;string&lt;/span&gt; replyToAddress
= &lt;span style="COLOR: #0000ff"&gt;string&lt;/span&gt;.Empty; SPSecurity.RunWithElevatedPrivileges(&lt;span style="COLOR: #0000ff"&gt;delegate&lt;/span&gt;()
{ SPAdministrationWebApplication adminApp = Microsoft.SharePoint.Administration.SPAdministrationWebApplication.Local;
SPOutboundMailServiceInstance emailService = adminApp.OutboundMailServiceInstance;
smtp = emailService.Server.Address; fromAddress = adminApp.OutboundMailSenderAddress;
replyToAddress = adminApp.OutboundMailReplyToAddress; &lt;span style="COLOR: #0000ff"&gt;if&lt;/span&gt; (!&lt;span style="COLOR: #0000ff"&gt;string&lt;/span&gt;.IsNullOrEmpty(&lt;span style="COLOR: #0000ff"&gt;this&lt;/span&gt;.To))
{ SmtpClient mail = &lt;span style="COLOR: #0000ff"&gt;new&lt;/span&gt; SmtpClient(); MailMessage
message = &lt;span style="COLOR: #0000ff"&gt;new&lt;/span&gt; MailMessage(); message.From = &lt;span style="COLOR: #0000ff"&gt;new&lt;/span&gt; MailAddress(fromAddress);
message.To.Add(&lt;span style="COLOR: #0000ff"&gt;this&lt;/span&gt;.To); &lt;span style="COLOR: #0000ff"&gt;if&lt;/span&gt; (!&lt;span style="COLOR: #0000ff"&gt;string&lt;/span&gt;.IsNullOrEmpty(replyToAddress))
message.ReplyTo = &lt;span style="COLOR: #0000ff"&gt;new&lt;/span&gt; MailAddress(replyToAddress); &lt;span style="COLOR: #0000ff"&gt;if&lt;/span&gt; (!&lt;span style="COLOR: #0000ff"&gt;string&lt;/span&gt;.IsNullOrEmpty(&lt;span style="COLOR: #0000ff"&gt;this&lt;/span&gt;.Subject))
message.Subject = &lt;span style="COLOR: #0000ff"&gt;this&lt;/span&gt;.Subject; &lt;span style="COLOR: #0000ff"&gt;if&lt;/span&gt; (!&lt;span style="COLOR: #0000ff"&gt;string&lt;/span&gt;.IsNullOrEmpty(&lt;span style="COLOR: #0000ff"&gt;this&lt;/span&gt;.Body))
message.Body = &lt;span style="COLOR: #0000ff"&gt;this&lt;/span&gt;.Body; message.IsBodyHtml = &lt;span style="COLOR: #0000ff"&gt;this&lt;/span&gt;.IsHtml;
mail.Host = smtp; mail.Send(message); } }); } }&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;
So - if you want to write your own, there you go!
&lt;/p&gt;
&lt;p&gt;
Sigh...
&lt;/p&gt;
&lt;p&gt;
After I put this together, I found that you can send email from within the SPUtility
object.&amp;nbsp; SPUtility.SendEmail() will take care of all this for you, too.&amp;nbsp; 
&lt;/p&gt;
&lt;img width="0" height="0" src="http://blog.richfinn.net/blog/aggbug.ashx?id=ef5c964f-ad19-4bdf-855d-69a894950a93" /&gt;</description>
      <comments>http://blog.richfinn.net/blog/CommentView,guid,ef5c964f-ad19-4bdf-855d-69a894950a93.aspx</comments>
      <category>Development</category>
      <category>Microsoft Office SharePoint Server</category>
    </item>
    <item>
      <trackback:ping>http://blog.richfinn.net/blog/Trackback.aspx?guid=c8588c53-a393-441d-b6ac-fa7952c74336</trackback:ping>
      <pingback:server>http://blog.richfinn.net/blog/pingback.aspx</pingback:server>
      <pingback:target>http://blog.richfinn.net/blog/PermaLink,guid,c8588c53-a393-441d-b6ac-fa7952c74336.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://blog.richfinn.net/blog/CommentView,guid,c8588c53-a393-441d-b6ac-fa7952c74336.aspx</wfw:comment>
      <wfw:commentRss>http://blog.richfinn.net/blog/SyndicationService.asmx/GetEntryCommentsRss?guid=c8588c53-a393-441d-b6ac-fa7952c74336</wfw:commentRss>
      <slash:comments>1</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I'm working on a site which uses Forms Based Authentication, and I want to extend
the standard user profile with some of my own custom properties.
</p>
        <p>
I knew you could define a ProfileProvider in the MOSS web.config file, but the tricky
part was getting and setting the values since the framework is unaware of the provider. 
You can't access the properties at design-time like a normal Asp.Net Web Application,
and I couldn't find any documentation for accessing Profile Provider Properties as
a collection like <em>propcollection["propname"]</em>.  I've seen a couple places
where people talk about creating and using custom profile provider properties in MOSS,
but there was nowhere that explained how to do it.
</p>
        <p>
Then, yesterday there was <a href="http://feeds.feedburner.com/~r/sharepointteamblog/~3/192744732/moss-2007-profile-import-tool-now-available-at-http-www-codeplex-com-sptoolbox.aspx" target="_blank">the
post on the MOSS Team Blog</a> about the <a href="http://www.codeplex.com/Release/ProjectReleases.aspx?ProjectName=sptoolbox&amp;ReleaseId=8728" target="_blank">Profile
Import Tool</a> being released on CodePlex - which is very cool in itself.  I
figured, <a href="http://www.codeplex.com" target="_blank">CodePlex</a> - open source;
Profile Import - I bet they have code in their project that gets the properties out
in the way I need since it's a dynamic process for importing profile property values. 
Bingo!  Thank you Steve, Ron, and <a href="http://blogs.technet.com/lliu" target="_blank">Lawrence</a>!
</p>
        <p>
Here's the code I used to Get/Set a custom profile property named 'UserCity' for the
current user in MOSS, most of which was pulled and pieced together from the Profile
Import Tool project:
</p>
        <p>
          <strong>Profile section in MOSS web.config:</strong>
        </p>
        <div style="BORDER-RIGHT: gray 1px solid; PADDING-RIGHT: 4px; BORDER-TOP: gray 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 8pt; PADDING-BOTTOM: 4px; MARGIN: 20px 0px 10px; OVERFLOW: auto; BORDER-LEFT: gray 1px solid; WIDTH: 97.5%; CURSOR: text; MAX-HEIGHT: 200px; LINE-HEIGHT: 12pt; PADDING-TOP: 4px; BORDER-BOTTOM: gray 1px solid; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BACKGROUND-COLOR: #f4f4f4">
          <pre style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none">
            <span style="COLOR: #0000ff">&lt;</span>
            <span style="COLOR: #800000">profile</span>
            <span style="COLOR: #ff0000">defaultProvider</span>
            <span style="COLOR: #0000ff">="MOSSPortalProfile"</span>
            <span style="COLOR: #ff0000">enabled</span>
            <span style="COLOR: #0000ff">="true"</span>
            <span style="COLOR: #ff0000">automaticSaveEnabled</span>
            <span style="COLOR: #0000ff">="true"</span>
            <span style="COLOR: #0000ff">&gt;</span>
            <span style="COLOR: #0000ff">&lt;</span>
            <span style="COLOR: #800000">providers</span>
            <span style="COLOR: #0000ff">&gt;</span>
            <span style="COLOR: #0000ff">&lt;</span>
            <span style="COLOR: #800000">add</span>
            <span style="COLOR: #ff0000">connectionStringName</span>
            <span style="COLOR: #0000ff">="AspNetDb_ConnectionString"</span>
            <span style="COLOR: #ff0000">applicationName</span>
            <span style="COLOR: #0000ff">="MOSSPortal"</span>
            <span style="COLOR: #ff0000">name</span>
            <span style="COLOR: #0000ff">="MOSSPortalProfile"</span>
            <span style="COLOR: #ff0000">type</span>
            <span style="COLOR: #0000ff">="System.Web.Profile.SqlProfileProvider,System.Web,Version=2.0.0.0,Culture=neutral,PublicKeyToken=b03f5f7f11d50a3a"</span>
            <span style="COLOR: #0000ff">/&gt;</span>
            <span style="COLOR: #0000ff">&lt;/</span>
            <span style="COLOR: #800000">providers</span>
            <span style="COLOR: #0000ff">&gt;</span>
            <span style="COLOR: #0000ff">&lt;</span>
            <span style="COLOR: #800000">properties</span>
            <span style="COLOR: #0000ff">&gt;</span>
            <span style="COLOR: #0000ff">&lt;</span>
            <span style="COLOR: #800000">add</span>
            <span style="COLOR: #ff0000">name</span>
            <span style="COLOR: #0000ff">="UserCity"</span>
            <span style="COLOR: #ff0000">customProviderData</span>
            <span style="COLOR: #0000ff">="DisplayName=City;"</span>
            <span style="COLOR: #0000ff">/&gt;</span>
            <span style="COLOR: #0000ff">&lt;/</span>
            <span style="COLOR: #800000">properties</span>
            <span style="COLOR: #0000ff">&gt;</span>
            <span style="COLOR: #0000ff">&lt;/</span>
            <span style="COLOR: #800000">profile</span>
            <span style="COLOR: #0000ff">&gt;</span>
          </pre>
        </div>
        <a href="http://11011.net/software/vspaste">
        </a>
        <p>
          <strong>
            <br />
            <br />
Get/Set C# code:</strong>
        </p>
        <div style="BORDER-RIGHT: gray 1px solid; PADDING-RIGHT: 4px; BORDER-TOP: gray 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 8pt; PADDING-BOTTOM: 4px; MARGIN: 20px 0px 10px; OVERFLOW: auto; BORDER-LEFT: gray 1px solid; WIDTH: 97.5%; CURSOR: text; MAX-HEIGHT: 200px; LINE-HEIGHT: 12pt; PADDING-TOP: 4px; BORDER-BOTTOM: gray 1px solid; FONT-FAMILY: consolas, 'Courier New', courier, monospace; HEIGHT: 223px; BACKGROUND-COLOR: #f4f4f4">
          <pre style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none">
            <span style="COLOR: #008000">//object
to hold the profile properties defined in the web config</span> SettingsPropertyCollection
profileProperties = <span style="COLOR: #0000ff">new</span> SettingsPropertyCollection(); <span style="COLOR: #008000">//get
the profile section from the web config</span> ProfileSection profileConfigSection
= (ProfileSection)ConfigurationManager.GetSection(<span style="COLOR: #006080">"system.web/profile"</span>); <span style="COLOR: #008000">//get
the collection of defined properties</span> RootProfilePropertySettingsCollection
configProperties = profileConfigSection.PropertySettings; <span style="COLOR: #008000">//create
collection to contains properties to pass to the profile provider</span> SettingsPropertyCollection
propertiesToReturn = <span style="COLOR: #0000ff">new</span> SettingsPropertyCollection(); <span style="COLOR: #008000">//populate
the collection with properties from the web config</span><span style="COLOR: #0000ff">foreach</span> (ProfilePropertySettings
configProperty <span style="COLOR: #0000ff">in</span> configProperties) { SettingsProperty
profileProperty = <span style="COLOR: #0000ff">new</span> SettingsProperty(configProperty.Name);
profileProperty.PropertyType = Type.GetType(configProperty.Type); <span style="COLOR: #0000ff">if</span> (profileProperty.PropertyType
== <span style="COLOR: #0000ff">null</span>) { profileProperty.PropertyType = <span style="COLOR: #0000ff">typeof</span>(System.String);
} profileProperty.DefaultValue = configProperty.DefaultValue; propertiesToReturn.Add(profileProperty);
} <span style="COLOR: #008000">//get the profile provider</span> ProfileProvider provider
= ProfileManager.Providers[<span style="COLOR: #006080">"MOSSPortalProfile"</span>]; <span style="COLOR: #008000">//create
a SettingsContext for the current user</span> SettingsContext userContext = <span style="COLOR: #0000ff">new</span> SettingsContext();
userContext[<span style="COLOR: #006080">"UserName"</span>] = SPContext.Current.Web.CurrentUser.Name;
userContext[<span style="COLOR: #006080">"IsAuthenticated"</span>] = <span style="COLOR: #0000ff">true</span>; <span style="COLOR: #008000">//get
the values of the properties for the current user from the database</span> SettingsPropertyValueCollection
returnVal = provider.GetPropertyValues(userContext, propertiesToReturn); <span style="COLOR: #008000">//get
the value out of the collection</span><span style="COLOR: #0000ff">string</span> contactCity
= Convert.ToString(returnVal[<span style="COLOR: #006080">"UserCity"</span>].PropertyValue); <span style="COLOR: #0000ff">if</span> (contactCity
== <span style="COLOR: #0000ff">string</span>.Empty) { contactCity = <span style="COLOR: #006080">"Denver"</span>;
} <span style="COLOR: #008000">//set value</span> returnVal[<span style="COLOR: #006080">"UserCity"</span>].PropertyValue
= contactCity; <span style="COLOR: #008000">//save user profile properties back to
the database</span> provider.SetPropertyValues(userContext, returnVal);</pre>
        </div>
        <br />
By the way, the <a href="http://www.codeplex.com/Project/ProjectDirectory.aspx?TagName=Sharepoint" target="_blank">SharePoint
project sites</a> on <a href="http://www.codeplex.com" target="_blank">CodePlex</a> are
great places to learn about the inner workings of WSS3/MOSS.  By scouring the
source code of the projects, you can extract some very cool ways to develop on the
platform.<img width="0" height="0" src="http://blog.richfinn.net/blog/aggbug.ashx?id=c8588c53-a393-441d-b6ac-fa7952c74336" /></body>
      <title>Get/Set custom profile properties in Profile Provider for MOSS</title>
      <guid isPermaLink="false">http://blog.richfinn.net/blog/PermaLink,guid,c8588c53-a393-441d-b6ac-fa7952c74336.aspx</guid>
      <link>http://blog.richfinn.net/blog/2007/11/30/GetSetCustomProfilePropertiesInProfileProviderForMOSS.aspx</link>
      <pubDate>Fri, 30 Nov 2007 18:34:14 GMT</pubDate>
      <description>&lt;p&gt;
I'm working on a site which uses Forms Based Authentication, and I want to extend
the standard user profile with some of my own custom properties.
&lt;/p&gt;
&lt;p&gt;
I knew you could define a ProfileProvider in the MOSS web.config file, but the tricky
part was getting and setting the values since the framework is unaware of the provider.&amp;nbsp;
You can't access the properties at design-time like a normal Asp.Net Web Application,
and I couldn't find any documentation for accessing Profile Provider Properties as
a collection like &lt;em&gt;propcollection["propname"]&lt;/em&gt;.&amp;nbsp; I've seen a couple places
where people talk about creating and using custom profile provider properties in MOSS,
but there was nowhere that explained how to do it.
&lt;/p&gt;
&lt;p&gt;
Then, yesterday there was &lt;a href="http://feeds.feedburner.com/~r/sharepointteamblog/~3/192744732/moss-2007-profile-import-tool-now-available-at-http-www-codeplex-com-sptoolbox.aspx" target=_blank&gt;the
post on the MOSS Team Blog&lt;/a&gt; about the &lt;a href="http://www.codeplex.com/Release/ProjectReleases.aspx?ProjectName=sptoolbox&amp;amp;ReleaseId=8728" target=_blank&gt;Profile
Import Tool&lt;/a&gt; being released on CodePlex - which is very cool in itself.&amp;nbsp; I
figured, &lt;a href="http://www.codeplex.com" target=_blank&gt;CodePlex&lt;/a&gt; - open source;
Profile Import - I bet they have code in their project that gets the properties out
in the way I need since it's a dynamic process for importing profile property values.&amp;nbsp;
Bingo!&amp;nbsp; Thank you Steve, Ron, and &lt;a href="http://blogs.technet.com/lliu" target=_blank&gt;Lawrence&lt;/a&gt;!
&lt;/p&gt;
&lt;p&gt;
Here's the code I used to Get/Set a custom profile property named 'UserCity' for the
current user in MOSS, most of which was pulled and pieced together from the Profile
Import Tool project:
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;Profile section in MOSS web.config:&lt;/strong&gt;
&lt;/p&gt;
&lt;div style="BORDER-RIGHT: gray 1px solid; PADDING-RIGHT: 4px; BORDER-TOP: gray 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 8pt; PADDING-BOTTOM: 4px; MARGIN: 20px 0px 10px; OVERFLOW: auto; BORDER-LEFT: gray 1px solid; WIDTH: 97.5%; CURSOR: text; MAX-HEIGHT: 200px; LINE-HEIGHT: 12pt; PADDING-TOP: 4px; BORDER-BOTTOM: gray 1px solid; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BACKGROUND-COLOR: #f4f4f4"&gt;&lt;pre style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none"&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #800000"&gt;profile&lt;/span&gt; &lt;span style="COLOR: #ff0000"&gt;defaultProvider&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;="MOSSPortalProfile"&lt;/span&gt; &lt;span style="COLOR: #ff0000"&gt;enabled&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;="true"&lt;/span&gt; &lt;span style="COLOR: #ff0000"&gt;automaticSaveEnabled&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;="true"&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;gt;&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #800000"&gt;providers&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;gt;&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #800000"&gt;add&lt;/span&gt; &lt;span style="COLOR: #ff0000"&gt;connectionStringName&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;="AspNetDb_ConnectionString"&lt;/span&gt; &lt;span style="COLOR: #ff0000"&gt;applicationName&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;="MOSSPortal"&lt;/span&gt; &lt;span style="COLOR: #ff0000"&gt;name&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;="MOSSPortalProfile"&lt;/span&gt; &lt;span style="COLOR: #ff0000"&gt;type&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;="System.Web.Profile.SqlProfileProvider,System.Web,Version=2.0.0.0,Culture=neutral,PublicKeyToken=b03f5f7f11d50a3a"&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;/&amp;gt;&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #800000"&gt;providers&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;gt;&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #800000"&gt;properties&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;gt;&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #800000"&gt;add&lt;/span&gt; &lt;span style="COLOR: #ff0000"&gt;name&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;="UserCity"&lt;/span&gt; &lt;span style="COLOR: #ff0000"&gt;customProviderData&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;="DisplayName=City;"&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;/&amp;gt;&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #800000"&gt;properties&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;gt;&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #800000"&gt;profile&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt; 
&lt;p&gt;
&lt;strong&gt;
&lt;br&gt;
&lt;br&gt;
Get/Set C# code:&lt;/strong&gt;
&lt;/p&gt;
&lt;div style="BORDER-RIGHT: gray 1px solid; PADDING-RIGHT: 4px; BORDER-TOP: gray 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 8pt; PADDING-BOTTOM: 4px; MARGIN: 20px 0px 10px; OVERFLOW: auto; BORDER-LEFT: gray 1px solid; WIDTH: 97.5%; CURSOR: text; MAX-HEIGHT: 200px; LINE-HEIGHT: 12pt; PADDING-TOP: 4px; BORDER-BOTTOM: gray 1px solid; FONT-FAMILY: consolas, 'Courier New', courier, monospace; HEIGHT: 223px; BACKGROUND-COLOR: #f4f4f4"&gt;&lt;pre style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none"&gt;&lt;span style="COLOR: #008000"&gt;//object
to hold the profile properties defined in the web config&lt;/span&gt; SettingsPropertyCollection
profileProperties = &lt;span style="COLOR: #0000ff"&gt;new&lt;/span&gt; SettingsPropertyCollection(); &lt;span style="COLOR: #008000"&gt;//get
the profile section from the web config&lt;/span&gt; ProfileSection profileConfigSection
= (ProfileSection)ConfigurationManager.GetSection(&lt;span style="COLOR: #006080"&gt;"system.web/profile"&lt;/span&gt;); &lt;span style="COLOR: #008000"&gt;//get
the collection of defined properties&lt;/span&gt; RootProfilePropertySettingsCollection
configProperties = profileConfigSection.PropertySettings; &lt;span style="COLOR: #008000"&gt;//create
collection to contains properties to pass to the profile provider&lt;/span&gt; SettingsPropertyCollection
propertiesToReturn = &lt;span style="COLOR: #0000ff"&gt;new&lt;/span&gt; SettingsPropertyCollection(); &lt;span style="COLOR: #008000"&gt;//populate
the collection with properties from the web config&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;foreach&lt;/span&gt; (ProfilePropertySettings
configProperty &lt;span style="COLOR: #0000ff"&gt;in&lt;/span&gt; configProperties) { SettingsProperty
profileProperty = &lt;span style="COLOR: #0000ff"&gt;new&lt;/span&gt; SettingsProperty(configProperty.Name);
profileProperty.PropertyType = Type.GetType(configProperty.Type); &lt;span style="COLOR: #0000ff"&gt;if&lt;/span&gt; (profileProperty.PropertyType
== &lt;span style="COLOR: #0000ff"&gt;null&lt;/span&gt;) { profileProperty.PropertyType = &lt;span style="COLOR: #0000ff"&gt;typeof&lt;/span&gt;(System.String);
} profileProperty.DefaultValue = configProperty.DefaultValue; propertiesToReturn.Add(profileProperty);
} &lt;span style="COLOR: #008000"&gt;//get the profile provider&lt;/span&gt; ProfileProvider provider
= ProfileManager.Providers[&lt;span style="COLOR: #006080"&gt;"MOSSPortalProfile"&lt;/span&gt;]; &lt;span style="COLOR: #008000"&gt;//create
a SettingsContext for the current user&lt;/span&gt; SettingsContext userContext = &lt;span style="COLOR: #0000ff"&gt;new&lt;/span&gt; SettingsContext();
userContext[&lt;span style="COLOR: #006080"&gt;"UserName"&lt;/span&gt;] = SPContext.Current.Web.CurrentUser.Name;
userContext[&lt;span style="COLOR: #006080"&gt;"IsAuthenticated"&lt;/span&gt;] = &lt;span style="COLOR: #0000ff"&gt;true&lt;/span&gt;; &lt;span style="COLOR: #008000"&gt;//get
the values of the properties for the current user from the database&lt;/span&gt; SettingsPropertyValueCollection
returnVal = provider.GetPropertyValues(userContext, propertiesToReturn); &lt;span style="COLOR: #008000"&gt;//get
the value out of the collection&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;string&lt;/span&gt; contactCity
= Convert.ToString(returnVal[&lt;span style="COLOR: #006080"&gt;"UserCity"&lt;/span&gt;].PropertyValue); &lt;span style="COLOR: #0000ff"&gt;if&lt;/span&gt; (contactCity
== &lt;span style="COLOR: #0000ff"&gt;string&lt;/span&gt;.Empty) { contactCity = &lt;span style="COLOR: #006080"&gt;"Denver"&lt;/span&gt;;
} &lt;span style="COLOR: #008000"&gt;//set value&lt;/span&gt; returnVal[&lt;span style="COLOR: #006080"&gt;"UserCity"&lt;/span&gt;].PropertyValue
= contactCity; &lt;span style="COLOR: #008000"&gt;//save user profile properties back to
the database&lt;/span&gt; provider.SetPropertyValues(userContext, returnVal);&lt;/pre&gt;
&lt;/div&gt;
&lt;br&gt;
By the way, the &lt;a href="http://www.codeplex.com/Project/ProjectDirectory.aspx?TagName=Sharepoint" target=_blank&gt;SharePoint
project sites&lt;/a&gt; on &lt;a href="http://www.codeplex.com" target=_blank&gt;CodePlex&lt;/a&gt; are
great places to learn about the inner workings of WSS3/MOSS.&amp;nbsp; By scouring the
source code of the projects, you can extract some very cool ways to develop on the
platform.&lt;img width="0" height="0" src="http://blog.richfinn.net/blog/aggbug.ashx?id=c8588c53-a393-441d-b6ac-fa7952c74336" /&gt;</description>
      <comments>http://blog.richfinn.net/blog/CommentView,guid,c8588c53-a393-441d-b6ac-fa7952c74336.aspx</comments>
      <category>Microsoft Office SharePoint Server</category>
      <category>Development</category>
    </item>
  </channel>
</rss>