<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>entwicklungsgedanken &#187; feature</title>
	<atom:link href="http://www.entwicklungsgedanken.de/tag/feature/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.entwicklungsgedanken.de</link>
	<description>Verschiedene Gedanken rund um die Softwareentwicklung</description>
	<lastBuildDate>Thu, 29 Jul 2010 11:09:20 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Inconvenient class-naming with feature receiver and scope=&#8221;Farm&#8221;</title>
		<link>http://www.entwicklungsgedanken.de/2008/12/11/inconvenient-class-naming-with-feature-receiver-and-scopefarm/</link>
		<comments>http://www.entwicklungsgedanken.de/2008/12/11/inconvenient-class-naming-with-feature-receiver-and-scopefarm/#comments</comments>
		<pubDate>Thu, 11 Dec 2008 00:36:20 +0000</pubDate>
		<dc:creator>Eric Bartels</dc:creator>
				<category><![CDATA[SharePoint]]></category>
		<category><![CDATA[SharePoint-Development]]></category>
		<category><![CDATA[Farm]]></category>
		<category><![CDATA[feature]]></category>
		<category><![CDATA[Inconvenient]]></category>
		<category><![CDATA[Receiver]]></category>
		<category><![CDATA[Scope]]></category>

		<guid isPermaLink="false">http://www.entwicklungsgedanken.de/?p=127</guid>
		<description><![CDATA[Writing feature receivers during SharePoint customizing a common task. Depending on the scope your features belongs to your code looks similar to the following: public override void FeatureActivated&#40;SPFeatureReceiverProperties properties&#41; &#123; // Scope=&#34;Web&#34; SPWeb web = properties.Feature.Parent as SPWeb; &#160; // Scope=&#34;Site&#34; SPSite site = properties.Feature.Parent as SPSite; &#160; // Scope=&#34;WebApplication&#34; SPWebApplication app = properties.Feature.Parent as [...]]]></description>
			<content:encoded><![CDATA[<p>Writing feature receivers during SharePoint customizing a common task. Depending on the scope your features belongs to your code looks similar to the following:</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF;">public</span> <span style="color: #0600FF;">override</span> <span style="color: #0600FF;">void</span> FeatureActivated<span style="color: #000000;">&#40;</span>SPFeatureReceiverProperties properties<span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
  <span style="color: #008080; font-style: italic;">// Scope=&quot;Web&quot;</span>
  SPWeb web <span style="color: #008000;">=</span> properties.<span style="color: #0000FF;">Feature</span>.<span style="color: #0000FF;">Parent</span> <span style="color: #0600FF;">as</span> SPWeb<span style="color: #008000;">;</span>
&nbsp;
  <span style="color: #008080; font-style: italic;">// Scope=&quot;Site&quot;</span>
  SPSite site <span style="color: #008000;">=</span> properties.<span style="color: #0000FF;">Feature</span>.<span style="color: #0000FF;">Parent</span> <span style="color: #0600FF;">as</span> SPSite<span style="color: #008000;">;</span>
&nbsp;
  <span style="color: #008080; font-style: italic;">// Scope=&quot;WebApplication&quot;</span>
  SPWebApplication app <span style="color: #008000;">=</span> properties.<span style="color: #0000FF;">Feature</span>.<span style="color: #0000FF;">Parent</span> <span style="color: #0600FF;">as</span> SPWebApplication<span style="color: #008000;">;</span>
&nbsp;
  <span style="color: #008080; font-style: italic;">// Scope=&quot;Farm&quot;. Does not work</span>
  SPFarm farm <span style="color: #008000;">=</span> properties.<span style="color: #0000FF;">Feature</span>.<span style="color: #0000FF;">Parent</span> <span style="color: #0600FF;">as</span> SPFarm<span style="color: #008000;">;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

<h3>Farm != SPFarm</h3>
<p>So the last line in the example code does not work. The variables <code>farm</code> is always <code>null</code>.</p>
<p>Here comes the great &#8220;<strong>SharePoint-naming-convention</strong>&#8220;&#8230; The class to get a farm-context is named <code>SPWebService</code>!</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF;">public</span> <span style="color: #0600FF;">override</span> <span style="color: #0600FF;">void</span> FeatureActivated<span style="color: #000000;">&#40;</span>SPFeatureReceiverProperties properties<span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
  <span style="color: #008080; font-style: italic;">// Scope=&quot;Farm&quot;. Works!</span>
  SPWebService farm <span style="color: #008000;">=</span> properties.<span style="color: #0000FF;">Feature</span>.<span style="color: #0000FF;">Parent</span> <span style="color: #0600FF;">as</span> SPWebService<span style="color: #008000;">;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.entwicklungsgedanken.de/2008/12/11/inconvenient-class-naming-with-feature-receiver-and-scopefarm/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Setting the MasterPage during feature activation sometimes works but not always?</title>
		<link>http://www.entwicklungsgedanken.de/2008/07/23/setting-the-masterpage-during-feature-activation-sometimes-works-but-not-always/</link>
		<comments>http://www.entwicklungsgedanken.de/2008/07/23/setting-the-masterpage-during-feature-activation-sometimes-works-but-not-always/#comments</comments>
		<pubDate>Wed, 23 Jul 2008 11:53:08 +0000</pubDate>
		<dc:creator>Eric Bartels</dc:creator>
				<category><![CDATA[SharePoint]]></category>
		<category><![CDATA[SharePoint-Development]]></category>
		<category><![CDATA[custom]]></category>
		<category><![CDATA[feature]]></category>
		<category><![CDATA[masterpage]]></category>

		<guid isPermaLink="false">http://www.entwicklungsgedanken.de/?p=57</guid>
		<description><![CDATA[One of my current projects had the requirement to modify certain properties of the SharePoint &#8220;Look and feel&#8221;. To make updates and improvements easy I created a custom masterpage which is provisioned via a Feature. A custom feature receiver takes care of setting the masterpage and a feature staple takes care of newly created webs. [...]]]></description>
			<content:encoded><![CDATA[<p>
One of my current projects had the requirement to modify certain properties of the SharePoint &#8220;Look and feel&#8221;.</p>
<p>
To make updates and improvements easy I created a custom masterpage which is provisioned via a Feature. A custom feature receiver takes care of setting the masterpage and a feature staple takes care of newly created webs.
</p>
<h3>Strange things</h3>
<p>
This works well &#8230; Well mostly. In some existing webs my custom masterpage is simply not attached.
</p>
<h3>Solution</h3>
<p>If you set the <code>SPWeb.MasterUrl</code> do not forget to set the <code>SPWeb.CustomMasterUrl</code>, too!</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #008080; font-style: italic;">// web = SPWeb</span>
web.<span style="color: #0000FF;">MasterUrl</span> <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;myPath/to/my.master&quot;</span><span style="color: #008000;">;</span>
web.<span style="color: #0000FF;">CustomMasterUrl</span> <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;myPath/to/my.master&quot;</span><span style="color: #008000;">;</span></pre></div></div>

<p>
Now my masterpage is attached and used as desired.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.entwicklungsgedanken.de/2008/07/23/setting-the-masterpage-during-feature-activation-sometimes-works-but-not-always/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
