<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Andy Burns' SharePoint Blog</title>
	
	<link>http://www.novolocus.com</link>
	<description>Whatever I'm working on, really...</description>
	<lastBuildDate>Mon, 30 Apr 2012 15:10:34 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/novolocus" /><feedburner:info uri="novolocus" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><feedburner:emailServiceId>novolocus</feedburner:emailServiceId><feedburner:feedburnerHostname>http://feedburner.google.com</feedburner:feedburnerHostname><item>
		<title>Working with the TaxonomyClientService: Part 4 – Populating Values with the Lists web service</title>
		<link>http://feedproxy.google.com/~r/novolocus/~3/9S98y1klO1A/</link>
		<comments>http://www.novolocus.com/2012/04/30/working-with-the-taxonomyclientservice-part-4-populating-values-with-the-lists-web-service/#comments</comments>
		<pubDate>Mon, 30 Apr 2012 15:10:34 +0000</pubDate>
		<dc:creator>Andy</dc:creator>
				<category><![CDATA[Development 2010]]></category>
		<category><![CDATA[Taxonomy]]></category>
		<category><![CDATA[Web Services]]></category>

		<guid isPermaLink="false">http://www.novolocus.com/?p=2377</guid>
		<description><![CDATA[So far I&#8217;ve discussed how to get information about getting the types of taxonomy field, working with those fields, and how to get term sets. What about setting values on list items? It isn&#8217;t immediately obvious how to do that. &#8230; <a href="http://www.novolocus.com/2012/04/30/working-with-the-taxonomyclientservice-part-4-populating-values-with-the-lists-web-service/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>So far I&#8217;ve discussed how to get information about <a title="Working with the TaxonomyClientService: Part 1 – What fields are there?" href="http://www.novolocus.com/2012/02/06/working-with-the-taxonomyclientservice-part-1-what-fields-are-there/">getting the types of taxonomy field</a>, <a title="Working with the TaxonomyClientService: Part 2 – Get the TermSet (and understand it!)" href="http://www.novolocus.com/2012/02/09/working-with-the-taxonomyclientservice-part-2-get-the-termset-and-understand-it/">working with those fields</a>, and <a href="http://www.novolocus.com/2012/04/26/working-with-the-taxonomyclientservice-part-3-caching/">how to get term sets</a>. What about setting values on list items?</p>
<p>It isn&#8217;t immediately obvious how to do that. For a start, we wouldn&#8217;t actually be using the <strong>TaxonomyClientService</strong>. To set values on items, you use the <strong>Lists</strong> web service, using the <strong><a href="http://msdn.microsoft.com/en-us/library/lists.lists.updatelistitems(v=office.12).aspx">UpdateListItems()</a></strong> method. This accepts XML describing the field and values.</p>
<p>But what fields do we submit, and what values? After all, as mentioned in <a href="http://www.novolocus.com/2012/02/06/working-with-the-taxonomyclientservice-part-1-what-fields-are-there/">part 1</a>, there are two fields &#8211; one for the displayed value, and a hidden &#8216;notes&#8217; field that contains the actual data!</p>
<p>There was no documentation about how to set these values, and limited and contradictory information in blog posts, so I investigated&#8230;</p>
<p><span id="more-2377"></span></p>
<p>What you send depends on the type of field you&#8217;re trying to set. Normal managed metadata fields are different to the Enterprise Keywords field.</p>
<p><span style="text-decoration: underline;"><strong>For normal taxonomy fields</strong></span> &#8211; either single or multiple values &#8211; you send an empty &#8216;display&#8217; field, and populate the hidden field as below. This shows single and multi valued fields respectively, and the &#8216;_0&#8242; fields are the hidden notes fields:</p>
<pre class="brush: xml; title: ; notranslate">&lt;Field Name='SomeField'&gt;&lt;/Field&gt;
&lt;Field Name='SomeField_0'&gt;TermName1|12345678-0000-0000-0000-1234567890AB&lt;/Field&gt;
&lt;Field Name='SomeField2'&gt;&lt;/Field&gt;
&lt;Field Name='SomeField2_0'&gt;TermName1|12345678-0000-0000-0000-1234567890AB;TermName2|98765432-0000-0000-0000-BA0987654321&lt;/Field&gt;</pre>
<p>There are a number of blogs out there that suggest that you need to submit your term&#8217;s display name in the display field. You don&#8217;t. You also don&#8217;t need to submit term IDs, GUIDs or otherwise.</p>
<p>There are also blog posts suggesting that your values you submit to the hidden notes field have to be of the form:</p>
<p><code>2;#My Term|d511f3c7-377f-480f-aff6-beebecd3c675</code></p>
<p>In this form, the &#8217;2&#8242; would represent the term description on the hidden list of taxonomy terms that is stored in the site collection. (I think that this is effectively a cache, though quite why I&#8217;m not too sure)</p>
<p>There&#8217;s a problem with that though. To submit terms in that form we&#8217;d have to look up their ID on that cache list (which is laborious, and it&#8217;s a different value for each site collection). Also, what if the term hasn&#8217;t been cached already?</p>
<p>Well, other blogs posts (I&#8217;m afraid I&#8217;ve lost their reference) say that you should submit your values in the form:</p>
<p><code>-1;#My Term|d511f3c7-377f-480f-aff6-beebecd3c675</code></p>
<p>The &#8216;-1&#8242; is supposed to represent the fact that you don&#8217;t know what the ID is. But if you don&#8217;t know that, how does it get filled in?</p>
<p>Well, there is an event handler that runs for all lists that use a Managed Metadata field. It looks after populating the hidden list of taxonomy terms, and it will insert that ID into the value of an item. It also populates the display text for that Managed Metadata field, which is why we can submit an empty value to that field.</p>
<p>And, in fact, the &#8216;-1&#8242; is not only unnecessary &#8211; that event handler is smart enough to recognise if there is no ID of the term on the hidden list being submitted &#8211; but if you want your values to look <em>exactly</em> the same as standard SharePoint&#8217;s values, then you should submit your value in the form:</p>
<p><code>#My Term|d511f3c7-377f-480f-aff6-beebecd3c675</code></p>
<p>Submitting a value with -1 at the start of it does work &#8211; but the value stored internally is not identical to the value that would be stored if you had set it using the SharePoint User Interface.</p>
<p>Now, all of that was for normal Managed Metadata fields&#8230;</p>
<p><span style="text-decoration: underline;"><strong>Enterprise Keyword fields</strong></span> accepted values of a slightly different format. For reasons I can&#8217;t quite fathom, you seem to have to submit your values in the form:</p>
<pre class="brush: xml; title: ; notranslate">&lt;Field Name='TaxKeyword'&gt;;#&lt;/Field&gt;
&lt;Field Name='TaxKeywordTaxHTField'&gt;TermName1|12345678-0000-0000-0000-1234567890AB;TermName2|98765432-0000-0000-0000-BA0987654321&lt;/Field&gt;</pre>
<p>Note that the &#8216;Display&#8217; field has a value of ;# submitted to it. I don&#8217;t know why (again, I found this input via exhaustive seach), but the Enterprise Keywords field does not work if you submit an empty value for that field (as you would for a normal managed metadata field).</p>
<p><strong>Bonus information:</strong> As<a href="http://sadomovalex.blogspot.co.uk/2011/05/add-enterprise-keywords-field-into.html"> others have noted</a>, the Enterprise Keywords fields will always have the same names and GUIDs to identify them:</p>
<ul>
<li><strong>TaxKeyword</strong> &#8211; {23F27201-BEE3-471E-B2E7-B64FD8B7CA38}</li>
<li><strong>TaxKeywordTaxHTField</strong> &#8211; {1390A86A-23DA-45F0-8EFE-EF36EDADFB39}</li>
</ul>
<p><em>(For those of you interested, I determined the correct input by filling in a number of fields using SharePoint&#8217;s user interface. I then looked at the raw data stored against the list item for them. </em></p>
<p><em>Then I wrote a console application that used the web service to set those fields, and compared the value that was actually stored with the example values. The console application tried lots of different inputs &#8211; various combinations of having a lead ID, of that ID being zero or -1, of having the term text, of having the term GUID, separating values with ; or with ;# etc. &#8211; to determine what formats resulted in the correct output. What I&#8217;ve written above is based on those tests, and I&#8217;ve used these formats of input for an application that I&#8217;ve written, and it seems to be working okay.)</em></p>
<img src="http://feeds.feedburner.com/~r/novolocus/~4/9S98y1klO1A" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.novolocus.com/2012/04/30/working-with-the-taxonomyclientservice-part-4-populating-values-with-the-lists-web-service/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.novolocus.com/2012/04/30/working-with-the-taxonomyclientservice-part-4-populating-values-with-the-lists-web-service/</feedburner:origLink></item>
		<item>
		<title>Working with the TaxonomyClientService: Part 3 – Caching</title>
		<link>http://feedproxy.google.com/~r/novolocus/~3/f5hYOykAsU8/</link>
		<comments>http://www.novolocus.com/2012/04/26/working-with-the-taxonomyclientservice-part-3-caching/#comments</comments>
		<pubDate>Thu, 26 Apr 2012 15:00:39 +0000</pubDate>
		<dc:creator>Andy</dc:creator>
				<category><![CDATA[Development 2010]]></category>
		<category><![CDATA[Taxonomy]]></category>
		<category><![CDATA[Web Services]]></category>

		<guid isPermaLink="false">http://www.novolocus.com/?p=2373</guid>
		<description><![CDATA[In Part 2 of this series I described how to retrieve a TermSet, and interpret the results. I suggested using code: Fine, but what are these properties we&#8217;re passing into GetTermSets()? Well timeStamps is the time you last retrieved the &#8230; <a href="http://www.novolocus.com/2012/04/26/working-with-the-taxonomyclientservice-part-3-caching/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>In <a title="Working with the TaxonomyClientService: Part 2 – Get the TermSet (and understand it!)" href="http://www.novolocus.com/2012/02/09/working-with-the-taxonomyclientservice-part-2-get-the-termset-and-understand-it/">Part 2</a> of this series I described how to retrieve a TermSet, and interpret the results. I suggested using code:</p>
<pre class="brush: csharp; title: ; notranslate">string clientTimestamps = string.Format(&quot;&lt;timeStamp&gt;{0}&lt;/timeStamp&gt;&quot;, lastClientCacheTime );
string clientVersion = &quot;&lt;version&gt;1&lt;/version&gt;&quot;;
string termStoreIds = string.Format(&quot;&lt;termStoreId&gt;{0}&lt;/termStoreId&gt;&quot;, termStoreId.ToString(&quot;D&quot;));
string termSetIds = string.Format(&quot;&lt;termSetId&gt;{0}&lt;/termSetId&gt;&quot;, termSetId.ToString(&quot;D&quot;));
string serverTermSetTimestampXml;
string result = _wssTax.GetTermSets(termStoreIds, termSetIds, 1033, clientTimestamps, clientVersion, out serverTermSetTimestampXml);</pre>
<p>Fine, but what are these properties we&#8217;re passing into <strong><a href="http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.taxonomy.webservices.taxonomyclientservice.gettermsets.aspx">GetTermSets()</a></strong>?<span id="more-2373"></span></p>
<p>Well <em>timeStamps</em> is the time you last retrieved the term set as number of <strong><a href="http://msdn.microsoft.com/en-us/library/system.datetime.ticks.aspx">Ticks </a></strong>for that time. E.g.</p>
<pre class="brush: csharp; title: ; notranslate">long clientTime = 0;
if (File.Exists(taxonomyFileCachePath))
{
clientTime = File.GetLastWriteTimeUtc(taxonomyFileCachePath).Ticks;
}</pre>
<p><em>clientVersion</em> is described as:</p>
<blockquote><p>Collection of versions of the server that each TermSet was downloaded from (always <strong>1</strong> unless the client doesn&#8217;t have the TermSet, then it is <strong>0</strong>).</p></blockquote>
<p>That has me puzzled, so I always just send a version of 1.</p>
<p><em>termStoreIds </em>is the ID of the term store we want to get terms from.</p>
<p><em>termSetIds</em> is the term set we want to retrieve.</p>
<p><em>serverTermSetTimestampXml</em> is the an output parameter which contains the last edit times for each of the retrieved term sets.</p>
<p>You may notice that for the above parameters I keep talking about term sets &#8211; as if you format your XML strings with multiple entries you should be able to retrieve multiple term sets at the same time. To be honest, though, I reckon this might be more effort than it&#8217;s worth, so I&#8217;ve written my functions to retrieve one term set at a time.</p>
<p>So what do I get back?</p>
<p>If my last cached time is from before the last editted time on the server, I get back the XML for the term set.</p>
<p>If my last cached time is more recent than the last editted time on the server, I get back XML containing no terms.</p>
<p>Thus, my logic for caching becomes:</p>
<ul>
<li>Get the last time I cached the term set.</li>
<li>Call GetTermSets() on the web service.</li>
<li>If there are terms in the response then the term set was editted since I last cached them. Write these new terms to the cache.</li>
<li>Read the terms from the cache.</li>
<li>Return them.</li>
</ul>
<p>This would be something like:</p>
<pre class="brush: csharp; title: ; notranslate">long clientTime = 0;
 if (File.Exists(taxonomyFileCachePath))
 {
     clientTime = File.GetLastWriteTimeUtc(taxonomyFileCachePath).Ticks;
 }
 string clientTimestamps = string.Format(&quot;{0}&quot;, clientTime);
 string clientVersion = &quot;1&quot;;
 string termStoreIds = string.Format(&quot;{0}&quot;, termStoreId.ToString(&quot;D&quot;));
 string termSetIds = string.Format(&quot;{0}&quot;, termSetId.ToString(&quot;D&quot;));
 string serverTermSetTimestampXml;
 //HACK: Hardcoded Locale
 string result = _wssTax.GetTermSets(termStoreIds, termSetIds, 1033, clientTimestamps, clientVersion, out serverTermSetTimestampXml);
 // Get the terms from the Web Service Response as a list of 'WssTaxonomyTerm' objects.
 // WssTaxonomyTerm is my own class to represent a Term in a Termset
 terms = GetResultsFromString(result);
 XmlSerializer ser = new XmlSerializer(typeof(List));
 //Terms.count could be zero because we already have a cached version in a file locally.
 //If so, don't overwrite that file. We'll load from it below.
 //If we did get terms back, then they are more recent than our cache. Save them. They'll be loaded below.
 if (terms.Count &gt; 0)
 {
     using (FileStream fs = new FileStream(taxonomyFileCachePath, FileMode.Create, FileAccess.Write))
     {
         ser.Serialize(fs, terms);
     }
 }

if (File.Exists(taxonomyFileCachePath))
 {
     using (FileStream fs = new FileStream(taxonomyFileCachePath, FileMode.Open, FileAccess.Read))
     {
         terms = (List)ser.Deserialize(fs);
     }
 }

return terms;</pre>
<img src="http://feeds.feedburner.com/~r/novolocus/~4/f5hYOykAsU8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.novolocus.com/2012/04/26/working-with-the-taxonomyclientservice-part-3-caching/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.novolocus.com/2012/04/26/working-with-the-taxonomyclientservice-part-3-caching/</feedburner:origLink></item>
		<item>
		<title>Reminders on customising the RichTextField control in Publishing</title>
		<link>http://feedproxy.google.com/~r/novolocus/~3/4qj-_m5sVrk/</link>
		<comments>http://www.novolocus.com/2012/04/24/reminders-on-customising-the-richtextfield-control-in-publishing/#comments</comments>
		<pubDate>Tue, 24 Apr 2012 17:04:30 +0000</pubDate>
		<dc:creator>Andy</dc:creator>
				<category><![CDATA[Branding 2010]]></category>
		<category><![CDATA[Development 2010]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[RichTextField]]></category>

		<guid isPermaLink="false">http://www.novolocus.com/?p=2366</guid>
		<description><![CDATA[Right, so, again I&#8217;m looking at the problem of consistent formatting of client authored text in SharePoint. (Incredibly, it&#8217;s 4 years since I first looked at this). Anyway, as a note to myself&#8230; SharePointBlues has good post on how to &#8230; <a href="http://www.novolocus.com/2012/04/24/reminders-on-customising-the-richtextfield-control-in-publishing/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Right, so, again I&#8217;m looking at the problem of consistent formatting of client authored text in SharePoint. (Incredibly, it&#8217;s <a href="http://www.novolocus.com/2008/03/17/modify-the-richhtmlfield-control-on-your-page-layouts/">4 years since I first looked at this</a>).</p>
<p>Anyway, as a note to myself&#8230;<span id="more-2366"></span></p>
<ul>
<li>SharePointBlues has good post on <a href="http://www.sharepointblues.com/2010/10/27/custom-styles-for-sharepoint-2010-rich-html-field/">how to set up those custom styles</a>.</li>
<li>MSDN has an article about <a href="http://msdn.microsoft.com/en-us/library/ms561507.aspx">How to: Customize the SharePoint HTML Editor Field Control</a></li>
<li>Don&#8217;t forget to style things like lists and tables.</li>
<li>Don&#8217;t forget to set a minimum edit height.</li>
<li>Regarding the <a href="http://mosshowto.blogspot.co.uk/2009/12/sharepoint-2010-wiki-styles.html#1"> difference between Markup Styles and Styles</a>:
<ul>
<li>the &#8220;Markup Styles&#8221;
<ul>
<li>nest the text and its HTML tag within the html tag specified in the style if the tag to nest is a &lt;span&gt; element</li>
<li>replace the current tag if is is not a &lt;span&gt; element</li>
<li>remove all the styles for the children elements</li>
<li>remove the html tag if the same style is applied a second time (this is a way of removing a Markup style for an end-user)</li>
</ul>
</li>
<li>the &#8220;Styles&#8221;
<ul>
<li>nest the text in a &lt;span&gt; tag with the style class if the text is not already inside an HTML tag</li>
<li>just add the class to the current HTML tag if this tag is not a &lt;span&gt; tag</li>
<li>replace the class of the HTML tag if this tag is a &lt;span&gt; tag</li>
<li>remove the html &lt;span&gt; tag if the same style is applied a second time (this is a way of removing a Style for an end-user)</li>
</ul>
</li>
</ul>
</li>
<li>Consult the Out-of-box styles as examples. It&#8217;s in LAYOUTS\1033\STYLES\HtmlEditorStyles.css , and it&#8217;s actually a pretty well structured (if substantial) file.</li>
</ul>
<img src="http://feeds.feedburner.com/~r/novolocus/~4/4qj-_m5sVrk" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.novolocus.com/2012/04/24/reminders-on-customising-the-richtextfield-control-in-publishing/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.novolocus.com/2012/04/24/reminders-on-customising-the-richtextfield-control-in-publishing/</feedburner:origLink></item>
		<item>
		<title>RSS Feed in Office 365</title>
		<link>http://feedproxy.google.com/~r/novolocus/~3/49f8zMNfRMY/</link>
		<comments>http://www.novolocus.com/2012/04/24/rss-feed-in-office-365/#comments</comments>
		<pubDate>Tue, 24 Apr 2012 08:50:58 +0000</pubDate>
		<dc:creator>Andy</dc:creator>
				<category><![CDATA[Office 365]]></category>
		<category><![CDATA[Office365]]></category>
		<category><![CDATA[RSS]]></category>

		<guid isPermaLink="false">http://www.novolocus.com/?p=2362</guid>
		<description><![CDATA[This is just a quick note &#8211; that annoyingly, there isn&#8217;t an RSS feed web part (that functions) in Office 365. Even more frustratingly, the RSS Viewer Web Part is available, it just doesn&#8217;t work. When you add it to a &#8230; <a href="http://www.novolocus.com/2012/04/24/rss-feed-in-office-365/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>This is just a quick note &#8211; that annoyingly, there isn&#8217;t an RSS feed web part (that functions) in Office 365. Even more frustratingly, the RSS Viewer Web Part is <em>available</em>, it just doesn&#8217;t work. When you add it to a page, you get the warning:</p>
<blockquote><p>Web Part or Web Form Control on this Page cannot be displayed or imported. The type is not registered as safe</p></blockquote>
<p>This is <a href="http://support.microsoft.com/kb/2535012">discussed in KB2535012</a>, the main thrust of it being:</p>
<blockquote><p>This issue occurs because the RSS Viewer Web Part is not available in Office 365. This issue is scheduled to be resolved in a future version of Office 365.</p></blockquote>
<p>In fairness, this restriction is mentioned in the <a href="http://community.office365.com/en-us/w/release-notes/312.aspx#SharePointOnline">SharePoint Online Release notes</a>.</p>
<p>Alternatives?<span id="more-2362"></span> Well, they&#8217;re limited. Rene Modery has written<a href="http://modery.net/updated-rss-feed-web-part-for-office-365/"> a solution using JavaScript and the Google Feed AP</a>I (which should mean that there&#8217;s some caching of the feed, albeit on Google&#8217;s servers). It&#8217;s the main alternative that I&#8217;ve come across, and it&#8217;s how I&#8217;d approach the problem, although I think that authentication between your Google server, with it&#8217;s cache, and the target feed could be tricky.</p>
<p>There&#8217;s <a href="https://www.nothingbutsharepoint.com/sites/devwiki/articles/Pages/RSS-Feed-Web-Part-for-Office-365.aspx">more information on his approach here</a>.</p>
<p>And further evidence that it might be the only reasonable approach &#8211; Raghavendra Shanbhag <a href="http://moss-solutions.blogspot.co.uk/2011/08/jquery-rssreader-webpart-for-office365.html">describes doing the same sort of thing</a> with the zRSSFeed jQuery library.</p>
<p>Or, I guess the other alternative is to wait for Microsoft to fix this &#8211; and they have to, not having RSS in Office 365 SharePoint is absurd.</p>
<img src="http://feeds.feedburner.com/~r/novolocus/~4/49f8zMNfRMY" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.novolocus.com/2012/04/24/rss-feed-in-office-365/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.novolocus.com/2012/04/24/rss-feed-in-office-365/</feedburner:origLink></item>
		<item>
		<title>SharePoint Theme Settings page and Enhanced Theming</title>
		<link>http://feedproxy.google.com/~r/novolocus/~3/O5xV8yBQP2Q/</link>
		<comments>http://www.novolocus.com/2012/04/10/sharepoint-theme-settings-page-and-enhanced-theming/#comments</comments>
		<pubDate>Tue, 10 Apr 2012 15:00:42 +0000</pubDate>
		<dc:creator>Andy</dc:creator>
				<category><![CDATA[Admin]]></category>
		<category><![CDATA[Branding]]></category>
		<category><![CDATA[Features]]></category>
		<category><![CDATA[Themes]]></category>

		<guid isPermaLink="false">http://www.novolocus.com/?p=2334</guid>
		<description><![CDATA[If you create a site using the Blank template and go to Settings &#62; Site Theme you get a simple page that lets you set your site theme. If you create a site using the Team Site template and go to &#8230; <a href="http://www.novolocus.com/2012/04/10/sharepoint-theme-settings-page-and-enhanced-theming/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>If you create a site using the <em>Blank</em> template and go to <em>Settings &gt; Site Theme</em> you get a simple page that lets you set your site theme.<a href="http://www.novolocus.com/wp-content/uploads/2012/03/Simple-Theme-Page.png"><img class="aligncenter size-medium wp-image-2336" title="Simple Theme Page" src="http://www.novolocus.com/wp-content/uploads/2012/03/Simple-Theme-Page-300x106.png" alt="" width="300" height="106" /></a></p>
<p>If you create a site using the <em>Team Site</em> template and go to <em>Settings &gt; Site Theme</em>, you get a more advanced page.</p>
<p><a href="http://www.novolocus.com/wp-content/uploads/2012/03/Enhanced-Theme-Page.png"><img class="aligncenter size-medium wp-image-2335" title="Enhanced Theme Page" src="http://www.novolocus.com/wp-content/uploads/2012/03/Enhanced-Theme-Page-300x209.png" alt="" width="300" height="209" /></a></p>
<p>Both these experiences are supported by the one page (/<em>_layouts/themeweb.aspx</em>). So what gives?<span id="more-2334"></span></p>
<p>Well, themeweb.aspx contains two delegates placeholders, and there is a feature <strong>EnhancedTheming</strong> (ID: 068BC832-4951-11DC-8314-0800200C9A66) that contains controls to insert to them. This feature is hidden, but is used by a lot of the site templates &#8211; but not <em>Blank</em> sites. It&#8217;s also required by the publishing features.</p>
<p><em>(Actually, this feature is stapled to most of the site templates by the BaseSiteStapling feature)</em></p>
<p>So, could we turn this on for a <em>Blank</em> site? Obviously we can&#8217;t through the UI, but STSADM should let us.</p>
<p><code>stsadm -o activatefeature -name enhancedtheming -url [site url]</code></p>
<p>And voila! A <em>Blank</em> site with enhanced theming!</p>
<p>So why this structure? I know that the enhanced theming isn&#8217;t part of SharePoint Foundation, so having a feature that staples it to Site Definitions in full SharePoint makes sense. However, I must confess, I&#8217;m puzzled why is isn&#8217;t also stapled to <em>&#8216;Blank&#8217;</em> sites. I guess that maybe it&#8217;s to try and keep <em>Blank</em> sites, um, blank.</p>
<img src="http://feeds.feedburner.com/~r/novolocus/~4/O5xV8yBQP2Q" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.novolocus.com/2012/04/10/sharepoint-theme-settings-page-and-enhanced-theming/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.novolocus.com/2012/04/10/sharepoint-theme-settings-page-and-enhanced-theming/</feedburner:origLink></item>
		<item>
		<title>SPWeb.Properties serialization in the Sandbox</title>
		<link>http://feedproxy.google.com/~r/novolocus/~3/sn6Hz-b60kc/</link>
		<comments>http://www.novolocus.com/2012/04/05/spweb-properties-serialization-in-the-sandbox/#comments</comments>
		<pubDate>Thu, 05 Apr 2012 12:15:32 +0000</pubDate>
		<dc:creator>Andy</dc:creator>
				<category><![CDATA[Development 2010]]></category>
		<category><![CDATA[Sandbox]]></category>
		<category><![CDATA[Serialization]]></category>

		<guid isPermaLink="false">http://www.novolocus.com/?p=2307</guid>
		<description><![CDATA[I was trying to store and retrieve some properties on an SPWeb object inside the sandbox. SPWeb has SetProperty() and GetProperty() methods, which accept and retrieve objects. I thought I&#8217;d use an enumeration to represent my value, and I&#8217;d cast &#8230; <a href="http://www.novolocus.com/2012/04/05/spweb-properties-serialization-in-the-sandbox/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I was trying to store and retrieve some properties on an <strong>SPWeb</strong> object inside the sandbox. <strong>SPWeb</strong> has <a href="http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spweb.setproperty.aspx"><strong>SetProperty()</strong> </a>and <a href="http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spweb.getproperty.aspx"><strong>GetProperty()</strong> </a>methods, which accept and retrieve objects. I thought I&#8217;d use an enumeration to represent my value, and I&#8217;d cast my enumeration value when I retrieve it. However, when I tried this I got an exception of the form:</p>
<blockquote><p>System.Runtime.Serialization.SerializationException was unhandled Message=Unable to find assembly &#8216;&lt;my assembly strong name&gt;&#8217;</p></blockquote>
<p>Interesting. I tried similar code within a Console application using the full SharePoint API&#8230;<span id="more-2307"></span></p>
<pre class="brush: csharp; title: ; notranslate">    public enum Color
    {
        Red,
        Green,
        Blue
    }
    class Program
    {
        static void Main(string[] args)
        {
            string url = &quot;http://sp/&quot;;
            using (SPSite site = new SPSite(url))
            {
                using (SPWeb web = site.OpenWeb())
                {
                    web.SetProperty(&quot;TempKey&quot;, Color.Green);
                    Color c = (Color) web.GetProperty(&quot;TempKey&quot;);
                    Console.WriteLine(c);
                    Console.ReadLine();
                }
            }
        }
    }</pre>
<p>This worked fine, so it seemed to be something to do with the Sandbox. However, all the bits of the API I was using were allowed in the Sandbox. Eventually, I found the solution &#8211; and it turns out the problems is with <a href="http://fmuntean.wordpress.com/2010/06/29/serialization-inside-sandbox-solutions/">Serialization inside Sandbox solutions</a>. From Florin Muntean&#8217;s post:</p>
<blockquote><p>The problem is that the serialization mechanism inside .NET requires to load the assembly for reflection. The SandBox assembly can’t be found because it is not saved in the GAC or any of the SharePoint folders as it only resides in memory and on the Content Database.</p>
<p>A work around for this to create your own serialization to xml/string using custom methods that will save/restore your data using one of the .NET classes (that can be serialized because they live in GAC).</p></blockquote>
<p>Actually, it&#8217;s pretty obvious when someone explains it to you!</p>
<p>Following that advice, instead of storing the enumeration I stored the the <strong>.ToString()</strong> of it&#8217;s value, and parsed it back to the enum when I retrieved it:</p>
<pre class="brush: csharp; title: ; notranslate">public static LogLevel Level
{
    get
    {
		SPWeb rootWeb = SPContext.Current.Site.RootWeb;
		object obj = rootWeb.GetProperty(LoggingConsts.LOGLEVEL_PROPERTY);

		LogLevel lvl = LogLevel.None;
		if( obj != null ) {
			lvl = (LogLevel) Enum.Parse(typeof(LogLevel), obj.ToString());
		}
		return lvl;
    }
    set
    {
		SPWeb rootWeb = SPContext.Current.Site.RootWeb;
		rootWeb.SetProperty(LoggingConsts.LOGLEVEL_PROPERTY, value.ToString());
		rootWeb.Update();
    }
}</pre>
<p>And it worked like a charm. Nice one Florin!</p>
<img src="http://feeds.feedburner.com/~r/novolocus/~4/sn6Hz-b60kc" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.novolocus.com/2012/04/05/spweb-properties-serialization-in-the-sandbox/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.novolocus.com/2012/04/05/spweb-properties-serialization-in-the-sandbox/</feedburner:origLink></item>
		<item>
		<title>TFS, Versioning and Office 365 SharePoint</title>
		<link>http://feedproxy.google.com/~r/novolocus/~3/-SOedb_Y0m4/</link>
		<comments>http://www.novolocus.com/2012/04/03/tfs-versioning-and-office-365-sharepoint/#comments</comments>
		<pubDate>Tue, 03 Apr 2012 14:00:26 +0000</pubDate>
		<dc:creator>Andy</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Office365]]></category>
		<category><![CDATA[Sandbox]]></category>
		<category><![CDATA[TFS]]></category>

		<guid isPermaLink="false">http://www.novolocus.com/?p=2326</guid>
		<description><![CDATA[So, I am a big fan of putting build numbers or SVN revisions into the AssemblyFileVersion of my assemblies. I can then use a little bit of the System.Reflection API to get the AssemblyFileVersion, and display it to the user, write it to &#8230; <a href="http://www.novolocus.com/2012/04/03/tfs-versioning-and-office-365-sharepoint/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>So, I am a big fan of putting build numbers or SVN revisions into the <strong>AssemblyFileVersion</strong> of my assemblies. I can then use a little bit of the <strong>System.Reflection</strong> API to <a title="Assembly Versioning in SharePoint" href="http://www.novolocus.com/2011/05/18/assembly-versioning-in-sharepoint/">get the <strong>AssemblyFileVersion</strong></a>, and display it to the user, write it to logs, etc..</p>
<p>However, I ran into a hitch when working with Office 365. Although reflection worked fine on my local machine&#8217;s sandbox, I got an error when I tried to run the same code on Office 365&#8242;s SharePoint system. It was pretty obviously and emphatically using <strong>System.Reflection</strong> that was the problem.</p>
<p>This was a shame, as my build process is (as usual) putting the <strong>AssemblyFileVersion</strong> in. Sadly, I don&#8217;t see any easy way to get the <strong>AssemblyFileVersion</strong> value from within Office 365 code. So, alternatives?<span id="more-2326"></span></p>
<p>Well, my answer was a little &#8230; primitive. I added a CONST to my code:</p>
<pre class="brush: csharp; title: ; notranslate">const string SOLUTION_VERSION = &quot;Development&quot;;</pre>
<p>And I modified my build process to do a regex replace of that line in my code file during the build. I&#8217;d already written a build activity that would do a &#8220;regex find and replace in files&#8221;, so this was pretty simple to do.</p>
<p>The hard part, however, was deciding what the replacement pattern should be. The build process doesn&#8217;t seem to have any easy to use variables (our build processes are largely based on <a href="http://tfsversioning.codeplex.com/">TFS Versioning on CodePlex</a>).</p>
<p><em>(Note &#8211; from here on things get a little specific to what we use)</em></p>
<p>So, I chosed to the replacement pattern:</p>
<pre class="brush: vb; title: ; notranslate">String.Format(&quot;string SOLUTION_VERSION = &quot;&quot;{0}.{1}&quot;&quot;;&quot;,
    Regex.Replace(AssemblyFileVersionPattern, &quot;\.[^.]+\.[^.]+$&quot;, &quot;&quot;),
    Regex.Replace(LabelName, &quot;^.*_&quot;, &quot;&quot;))</pre>
<p>The first regex cuts the tail two elements off the <em>AssemblyFileVersionPattern </em>for our build, which is a variable we do have. By convention, in our build process, the front two elements are always numbers, and are manually altered when we move between versions.</p>
<p>The second regex cuts off the start of the build name. Our build name ends with the year and day of year, and the build revision for that day, just like our <strong>AssemblyFileVersion.</strong> Thus, the result of that regex is the tail two elements of our <strong>AssemblyFileVersion</strong>.</p>
<p>This results in a number of the form <em>1.2.12345.6</em> which is then inserted into our constant during the build process.</p>
<p><em>(Told you that the solution was a little bit specific to our process)</em></p>
<img src="http://feeds.feedburner.com/~r/novolocus/~4/-SOedb_Y0m4" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.novolocus.com/2012/04/03/tfs-versioning-and-office-365-sharepoint/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.novolocus.com/2012/04/03/tfs-versioning-and-office-365-sharepoint/</feedburner:origLink></item>
		<item>
		<title>MissingMethodException when calling SPWeb.Recycle() in Sandbox solution</title>
		<link>http://feedproxy.google.com/~r/novolocus/~3/tMVxLeIkqdI/</link>
		<comments>http://www.novolocus.com/2012/03/30/missingmethodexception-when-calling-spweb-recycle-in-sandbox-solution/#comments</comments>
		<pubDate>Fri, 30 Mar 2012 13:10:05 +0000</pubDate>
		<dc:creator>Andy</dc:creator>
				<category><![CDATA[Development 2010]]></category>
		<category><![CDATA[Sandbox]]></category>
		<category><![CDATA[SPWeb]]></category>

		<guid isPermaLink="false">http://www.novolocus.com/?p=2351</guid>
		<description><![CDATA[Service Pack 1 for SharePoint 2010 introduced a new method for the SPWeb object - Recycle(). This allows you to send a site to the recycle bin, rather than deleting it outright. I&#8217;ve used it before in Farm solutions without any &#8230; <a href="http://www.novolocus.com/2012/03/30/missingmethodexception-when-calling-spweb-recycle-in-sandbox-solution/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Service Pack 1 for SharePoint 2010 introduced a new method for the <strong>SPWeb</strong> object - <strong><a href="http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spweb.recycle.aspx">Recycle()</a></strong>. This allows you to send a site to the recycle bin, rather than deleting it outright. I&#8217;ve used it before in Farm solutions without any issue.</p>
<p>However, I&#8217;m now working on a sandbox solution, and when I tried using it, I got the error:</p>
<blockquote><p>MissingMethodException Method not found: &#8216;Void Microsoft.SharePoint.SPWeb_SubsetProxy.Recycle()&#8217;.<br />
at Microsoft.SharePoint.SPWeb.Recycle__Inner()<br />
at Microsoft.SharePoint.SPWeb.Recycle()</p></blockquote>
<p>Hmm. That&#8217;s strange; my call to recycle seems fine, and the documentation says it&#8217;s available in the Sandbox, but internally there seems to be a missing method.</p>
<p>Out of curiousity, I tried using <strong>Delete()</strong> rather than <strong>Recycle()</strong>, and this worked correctly. So what gives?<span id="more-2351"></span></p>
<p>Next I opened Reflector, and opened the <strong>Microsoft.SharePoint</strong> assembly from <em>14/Usercode</em>. Note that this <span style="text-decoration: underline;">is not</span> the same as the <strong>Microsoft.SharePoint</strong> assembly from <em>14/ISAPI</em>. The Usercode one is the assembly used in the Usercode service, and it is a subset of the full object model. It also works differently internally.</p>
<p>Anyway, I opened the <strong>SPWeb.Recycle__Inner()</strong> method:<a href="http://www.novolocus.com/wp-content/uploads/2012/03/RecycleInner.png"><img class="aligncenter size-full wp-image-2355" title="RecycleInner" src="http://www.novolocus.com/wp-content/uploads/2012/03/RecycleInner.png" alt="" width="292" height="150" /></a></p>
<p>Okay, only two lines. Long story short, I checked the <strong>SubsetOMEnabler.VerifySubsetOMEnabled()</strong> line, and it was doing something about controlling what OM was available. I couldn&#8217;t see anything that would result in the stacktrace I&#8217;d got, though.</p>
<p>However, the other line could. It casts an object to an <strong>SPWeb_SubsetProxy</strong> instance, and then calls<strong> Recycle()</strong> on it. This was the method that seemed to be missing, so I checked the <strong>SPWeb_SubsetProxy</strong> class to see if it had such a method.</p>
<p><a href="http://www.novolocus.com/wp-content/uploads/2012/03/No-Recycle-Method.png"><img class="aligncenter size-medium wp-image-2356" title="No Recycle Method" src="http://www.novolocus.com/wp-content/uploads/2012/03/No-Recycle-Method-300x195.png" alt="" width="300" height="195" /></a>Hmm. There&#8217;s a notable lack of a <strong>Recycle()</strong> method, just like the exception said.</p>
<p>So how does this compare with the <strong>SPWeb.Delete()</strong> method? Well, it uses the same pattern &#8211; a call to an inner method which casts the same object to an <strong>SPWeb_SubsetProxy</strong> class, and then it calls <strong>Delete()</strong> on the subset proxy.</p>
<p><a href="http://www.novolocus.com/wp-content/uploads/2012/03/DeleteInner.png"><img class="aligncenter size-medium wp-image-2353" title="DeleteInner" src="http://www.novolocus.com/wp-content/uploads/2012/03/DeleteInner-300x129.png" alt="" width="300" height="129" /></a></p>
<p>The difference is, though, that the <strong>SPWeb_SubsetProxy</strong> class actually <em>has</em> a<strong> Delete()</strong> method.</p>
<p><a href="http://www.novolocus.com/wp-content/uploads/2012/03/Delete-Method-Exists.png"><img class="aligncenter size-medium wp-image-2352" title="Delete Method Exists" src="http://www.novolocus.com/wp-content/uploads/2012/03/Delete-Method-Exists-300x121.png" alt="" width="300" height="121" /></a></p>
<p>Conclusions? Well, I&#8217;m not sure, but I think&#8230;</p>
<ul>
<li>The error message was right &#8211; the method appears to be missing.</li>
<li>Compilation of the usercode version of the Microsoft.SharePoint assembly probably didn&#8217;t pick it up due to the &#8216;cast and call a method on the resulting object&#8217; line. If it&#8217;d been:</li>
</ul>
<pre class="brush: csharp; title: ; notranslate">SPWeb_SubsetProxy px = (SPWeb_SubsetProxy)base.__InnerObj;
px.Recycle();</pre>
<p>&#8230; then I suspect the compiler would&#8217;ve complained.</p>
<ul>
<li>As this Object Model stands, it is not possible to recycle sites in Sandbox solutions. Which is sad, &#8216;cos that&#8217;s nice functionality.</li>
</ul>
<p>Has anyone else seen this problem? I was trying this on a machine that was patched up to the February 2012 Cumulative Updates.</p>
<p><em>(I&#8217;m a bit hesitant as often &#8216;faults&#8217; in APIs are down to developer understanding rather than actual faults, in my experience).</em></p>
<img src="http://feeds.feedburner.com/~r/novolocus/~4/tMVxLeIkqdI" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.novolocus.com/2012/03/30/missingmethodexception-when-calling-spweb-recycle-in-sandbox-solution/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://www.novolocus.com/2012/03/30/missingmethodexception-when-calling-spweb-recycle-in-sandbox-solution/</feedburner:origLink></item>
		<item>
		<title>TFS: Solution Explorer missing file status icons</title>
		<link>http://feedproxy.google.com/~r/novolocus/~3/R6v55AqtYY4/</link>
		<comments>http://www.novolocus.com/2012/03/27/tfs-solutio-explorer-missing-file-status-icons/#comments</comments>
		<pubDate>Tue, 27 Mar 2012 09:47:33 +0000</pubDate>
		<dc:creator>Andy</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[TFS]]></category>
		<category><![CDATA[Visual Studio]]></category>

		<guid isPermaLink="false">http://www.novolocus.com/?p=2320</guid>
		<description><![CDATA[I&#8217;ve just had a bit of a problem with Solution Explorer in Visual Studio not showing the &#8216;checkout status&#8217; icons from TFS &#8211; you know, the red tick, the padlock, etc.. These things: I couldn&#8217;t figure out what was causing this, but &#8230; <a href="http://www.novolocus.com/2012/03/27/tfs-solutio-explorer-missing-file-status-icons/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve just had a bit of a problem with Solution Explorer in Visual Studio not showing the &#8216;checkout status&#8217; icons from TFS &#8211; you know, the red tick, the padlock, etc.. These things:</p>
<p><a href="http://www.novolocus.com/wp-content/uploads/2012/03/Visual-Studio-Status-problems.png"><img class="aligncenter size-full wp-image-2321" title="Visual Studio Status problems" src="http://www.novolocus.com/wp-content/uploads/2012/03/Visual-Studio-Status-problems.png" alt="" width="264" height="301" /></a></p>
<p>I couldn&#8217;t figure out what was causing this, but <a href="http://social.msdn.microsoft.com/Forums/en/tfsgeneral/thread/58987d05-38d0-4056-82d7-f036adb7b2f3">found the solution </a>on MSDN forums:</p>
<blockquote><p>In VS 2010, while you have the solution open in Solution Explorer, select File-&gt; Source Control-&gt; Change Source Control, could you click on Bind for each project/solution? Binding provides version control functionality. This includes various version control icons that indicate status in Solution Explorer.</p></blockquote>
<p>This advice was correct &#8211; I went to the binding dialog, and the solution and projects weren&#8217;t bound. I added the bindings back &#8211; and presto. I&#8217;m not sure, however, how the project became unbound&#8230;</p>
<p>&nbsp;</p>
<img src="http://feeds.feedburner.com/~r/novolocus/~4/R6v55AqtYY4" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.novolocus.com/2012/03/27/tfs-solutio-explorer-missing-file-status-icons/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.novolocus.com/2012/03/27/tfs-solutio-explorer-missing-file-status-icons/</feedburner:origLink></item>
		<item>
		<title>No CssRegistration control in Sandbox</title>
		<link>http://feedproxy.google.com/~r/novolocus/~3/GfRvPsqRC5g/</link>
		<comments>http://www.novolocus.com/2012/03/16/no-cssregistration-control-in-sandbox/#comments</comments>
		<pubDate>Fri, 16 Mar 2012 12:18:40 +0000</pubDate>
		<dc:creator>Andy</dc:creator>
				<category><![CDATA[Development 2010]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[CSSRegistration]]></category>
		<category><![CDATA[Sandbox]]></category>
		<category><![CDATA[Web Parts]]></category>

		<guid isPermaLink="false">http://www.novolocus.com/?p=2315</guid>
		<description><![CDATA[Hmm &#8211; and interesting problem; in the Sandbox you don&#8217;t have any access to the CssRegistration class. It&#8217;s in the Microsoft.SharePoint.WebControls namespace, and you don&#8217;t have access to that. So, what do you do to link to an external stylesheet? &#8230; <a href="http://www.novolocus.com/2012/03/16/no-cssregistration-control-in-sandbox/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Hmm &#8211; and interesting problem; in the Sandbox you don&#8217;t have any access to the <a href="http://msdn.microsoft.com/en-us/library/ms443065.aspx"><strong>CssRegistration</strong> </a>class. It&#8217;s in the <em>Microsoft.SharePoint.WebControls</em> namespace, and you don&#8217;t have access to that.</p>
<p>So, what do you do to link to an external stylesheet? Um, well, there isn&#8217;t any pretty story. The best I&#8217;ve come across is by Ian Chivers, who uses JavaScript to add another <code>&lt;Link&gt;</code>  tag into the <code>&lt;Head&gt;</code> of the page.</p>
<ul>
<li><a href="http://blog.ianchivers.com/2011/11/add-stylesheet-to-page-from-sharepoint.html">Add a Stylesheet to a Page from a Sharepoint 2010 Sandbox WebPart</a></li>
</ul>
<p>Clever, but yuck!<span id="more-2315"></span></p>
<p>The explanation that <a href="http://social.technet.microsoft.com/Forums/en-US/sharepoint2010programming/thread/257c365f-e7f5-480e-9cee-724f023a45fd/">I came across by Mukul Sabharwal </a>(and seemed pretty good) was:</p>
<blockquote><p>Sandbox webparts do not execute in the same ASP.NET context as the page in which they reside, instead they execute in a distince ASP.NET context in a seperate worker process (UserCode Worker Process). SharePoint setups a make-believe world for the WebPart &#8212; specifically this make believe world consists of a single page with a single webpart zone and a single webpart &#8212; your sandbox webpart.</p>
<p>Once the webpart finishes execution the result is returned back to the main page. In fact, even if RegisterCssReference was not internal, there is no guarantee that the CSS could be applied, because we may have be too late in the ASP.NET page lifecycle to go do that.</p>
<p>This brings me to to answering your question, which is it is not currently possible to specify CSS into a page for a Sandbox Web Part.</p></blockquote>
<p>Makes sense &#8211; but some way of registering CSS might be useful.</p>
<p><strong>Edit: </strong>I tested Ali Robertson&#8217;s comment about just putting the <code>link </code>tag directly in the page, and that works.Unfortunately, there&#8217;s no way of then resolving Themed CSS files &#8211; something the <strong>CssRegistration</strong> class does &#8211; so you can&#8217;t have themed CSS in sandbox solutions (at least, as far as I can see at the moment).</p>
<img src="http://feeds.feedburner.com/~r/novolocus/~4/GfRvPsqRC5g" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.novolocus.com/2012/03/16/no-cssregistration-control-in-sandbox/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://www.novolocus.com/2012/03/16/no-cssregistration-control-in-sandbox/</feedburner:origLink></item>
		<item>
		<title>Sandbox Development – Reference the User Code DLL</title>
		<link>http://feedproxy.google.com/~r/novolocus/~3/DFuxHLHZB1g/</link>
		<comments>http://www.novolocus.com/2012/03/13/sandbox-development-reference-the-user-code-dll/#comments</comments>
		<pubDate>Tue, 13 Mar 2012 15:41:20 +0000</pubDate>
		<dc:creator>Andy</dc:creator>
				<category><![CDATA[Development 2010]]></category>
		<category><![CDATA[Sandbox]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[Web Parts]]></category>

		<guid isPermaLink="false">http://www.novolocus.com/?p=2303</guid>
		<description><![CDATA[Remarkably, I&#8217;ve only just started doing my first Sandboxed development in SharePoint 2010. (Most of our customers own their own servers, and want functionality you can&#8217;t easily build in the Sandbox alone). Anyway, I knew that the API you could use &#8230; <a href="http://www.novolocus.com/2012/03/13/sandbox-development-reference-the-user-code-dll/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Remarkably, I&#8217;ve only just started doing my first Sandboxed development in SharePoint 2010. <em>(Most of our customers own their own servers, and want functionality you can&#8217;t easily build in the Sandbox alone).</em></p>
<p>Anyway, I knew that the API you could use in the sandbox was smaller than the full API, and I wanted my solution to warn me (e.g. fail to compile) if I tried to use something that wasn&#8217;t available in the sandbox. I found two approaches&#8230;<span id="more-2303"></span></p>
<ol>
<li><strong>Replace the reference to <em>Microsoft.SharePoint.dll</em></strong>. If you instead reference the version for the sandbox ( in <code>14/UserCode/assemblies</code> ) and the project compiles successfully then it is a valid sandbox solution<em>.(Note: Only reference this dll for validation during development. You should reference the Mirosoft.Sharepoint.dll at <code>/14/ISAPI</code> for Release, although I&#8217;m not entirely sure why.)</em></li>
<li><strong>Use the <a href="http://visualstudiogallery.msdn.microsoft.com/8e602a8c-6714-4549-9e95-f3700344b0d9">SharePoint Power Tools Visual Studio Extension</a>.</strong> Not only does it give a Sandboxed Visual Web Part project (nice!), but it also changes Intellisense and compilation to use the Sandboxed API. Fantastic!</li>
</ol>
<p>Really, the Visual Studio extension is much simpler than changing and restoring assembly references, so I would always recommend it!</p>
<img src="http://feeds.feedburner.com/~r/novolocus/~4/DFuxHLHZB1g" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.novolocus.com/2012/03/13/sandbox-development-reference-the-user-code-dll/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.novolocus.com/2012/03/13/sandbox-development-reference-the-user-code-dll/</feedburner:origLink></item>
		<item>
		<title>Using SPMonitoredScope, Counters and SPCriticalTraceCounter</title>
		<link>http://feedproxy.google.com/~r/novolocus/~3/OLm4k66LRnU/</link>
		<comments>http://www.novolocus.com/2012/03/07/using-spmonitoredscope-and-spcriticaltracecounter/#comments</comments>
		<pubDate>Wed, 07 Mar 2012 15:27:15 +0000</pubDate>
		<dc:creator>Andy</dc:creator>
				<category><![CDATA[Development 2010]]></category>
		<category><![CDATA[Logging]]></category>
		<category><![CDATA[SPCriticalTraceCounter]]></category>
		<category><![CDATA[SPMonitoredScope]]></category>

		<guid isPermaLink="false">http://www.novolocus.com/?p=2291</guid>
		<description><![CDATA[Something that I don&#8217;t always remember &#8211; you can use the SPMonitoredScope class to monitor your SharePoint code as it executes. The results then get sent to the Developer Dashboard and ULS logs. There&#8217;s a decent description of it on &#8230; <a href="http://www.novolocus.com/2012/03/07/using-spmonitoredscope-and-spcriticaltracecounter/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Something that I don&#8217;t always remember &#8211; you can use the <strong><a href="http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.utilities.spmonitoredscope.aspx">SPMonitoredScope</a></strong> class to monitor your SharePoint code as it executes. The results then get sent to the Developer Dashboard and ULS logs. There&#8217;s a <a href="http://msdn.microsoft.com/en-us/library/ff512758.aspx">decent description of it on MSDN</a>.</p>
<pre class="brush: csharp; title: ; notranslate">using (new SPMonitoredScope(&quot;My Monitored Scope&quot;))
{
    // Do Stuff...
}</pre>
<p><span id="more-2291"></span>It&#8217;s worth noting that you can record more than just time (which I&#8217;d forgotten) &#8211; such as:</p>
<ul>
<li><strong><a href="http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.utilities.spsqlquerycounter.aspx">SPSqlQueryCounter</a></strong></li>
<li><strong><a href="http://msdn.microsoft.com/en-us/library/ee658659.aspx">SPRequestUsageCounter</a></strong></li>
<li><strong><a href="http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.utilities.spexecutiontimecounter.aspx">SPExecutionTimeCounter</a></strong></li>
</ul>
<p>I must confess, I&#8217;m not entirely sure what these are for. I can&#8217;t ever seem to get them to show much information, and doesn&#8217;t the <strong>SPMonitoredScope</strong> return the execution time anyway?</p>
<p>Also, while not quite the same sort of counter, there is also the <a href="http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.utilities.spcriticaltracecounter.aspx">SPCriticalTraceCounter</a>, that lets you record events&#8230;</p>
<pre class="brush: csharp; title: ; notranslate">SPCriticalTraceCounter.AddDataToScope(25, &quot;My Event&quot;, 15, &quot;Pop Goes the Weasel&quot;);</pre>
<p>I&#8217;ve <a title="FAIL: SPCriticalTraceCounter and TraceLevels" href="http://www.novolocus.com/2011/01/12/fail-spcriticaltracecounter-and-tracelevels/">mentioned them (and the &#8216;level&#8217; parameter) before</a>.</p>
<p>These produce quite nice outputs:</p>
<p><a href="http://www.novolocus.com/wp-content/uploads/2012/03/Developer-Dashboard.png"><img class="aligncenter size-medium wp-image-2292" title="Developer Dashboard" src="http://www.novolocus.com/wp-content/uploads/2012/03/Developer-Dashboard-300x107.png" alt="" width="300" height="107" /></a>Then<a href="http://msdn.microsoft.com/en-us/library/ff407304.aspx"> you can also get Performance Counter information </a>too.</p>
<pre class="brush: csharp; title: ; notranslate">SPHttpThrottleSettings throttleSettings =
      SPHttpThrottleSettings.GetHttpThrottleSettings(SPContext.Current.Site.WebApplication);
SPSystemPerformanceMonitorCollection monitors = throttleSettings.GenerateMonitors();
StringBuilder sb = new StringBuilder();
foreach (SPSystemPerformanceMonitor monitor in monitors)
{
	SPSystemPerformanceCounterMonitor counterMonitor = (SPSystemPerformanceCounterMonitor)monitor;
	sb.AppendFormat(&quot;{0} = {1}\n&quot;, counterMonitor.Name, counterMonitor.Value.ToString());
}</pre>
<p>For my system, that code output:<img class="aligncenter size-full wp-image-2293" title="Web Part showing Performance Counter Results" src="http://www.novolocus.com/wp-content/uploads/2012/03/Web-Part-showing-Performance-Counter-Results.png" alt="" width="248" height="42" /></p>
<p>I&#8217;m not quite sure what else you might be able to get from that. I&#8217;m also guessing that you probably need fairly high permissions to see some of that information&#8230;</p>
<img src="http://feeds.feedburner.com/~r/novolocus/~4/OLm4k66LRnU" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.novolocus.com/2012/03/07/using-spmonitoredscope-and-spcriticaltracecounter/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.novolocus.com/2012/03/07/using-spmonitoredscope-and-spcriticaltracecounter/</feedburner:origLink></item>
		<item>
		<title>Know whether your assembly is Debug or Release</title>
		<link>http://feedproxy.google.com/~r/novolocus/~3/d6HwY9HXcgU/</link>
		<comments>http://www.novolocus.com/2012/03/06/know-whether-your-assembly-is-debug-or-release/#comments</comments>
		<pubDate>Tue, 06 Mar 2012 18:47:22 +0000</pubDate>
		<dc:creator>Andy</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Assemblies]]></category>
		<category><![CDATA[Logging]]></category>

		<guid isPermaLink="false">http://www.novolocus.com/?p=2284</guid>
		<description><![CDATA[Sometimes, you want to know if your assembly is a Debug or Release build &#8211; like if you&#8217;re outputting assembly information for diagnostic purposes. But how do you know? Well, the easiest way would be to use C# Preprocessor Directives &#8230; <a href="http://www.novolocus.com/2012/03/06/know-whether-your-assembly-is-debug-or-release/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Sometimes, you want to know if your assembly is a Debug or Release build &#8211; like if you&#8217;re outputting assembly information for diagnostic purposes. But how do you know?<span id="more-2284"></span></p>
<p>Well, the easiest way would be to use C# Preprocessor Directives to change what your application does:</p>
<pre class="brush: csharp; title: ; notranslate">bool isDebug = false;
#if (DEBUG)
isDebug = true;
#else
isDebug = false;
#endif</pre>
<p>I know the <em>else</em> isn&#8217;t needed, but it&#8217;s to show the other condition too.</p>
<p>So, what is this magical value <strong>DEBUG</strong>? Well, it&#8217;s a preprocessor variable that is optionally added to your project at build time. By default, it&#8217;s true for Debug build, and not for Release builds. You can find it in the project settings:</p>
<p><a href="http://www.novolocus.com/wp-content/uploads/2012/03/DEBUG-symbol-added.png"><img class="aligncenter size-medium wp-image-2286" title="DEBUG symbol added" src="http://www.novolocus.com/wp-content/uploads/2012/03/DEBUG-symbol-added-300x132.png" alt="" width="300" height="132" /></a></p>
<p>You could also just put this information into the <em>AssemblyInfo.cs</em> file for your assembly with the same Preprocessor directives:</p>
<pre class="brush: csharp; title: ; notranslate">[assembly: AssemblyTitle(&quot;Example Assembly&quot;)]
#if (DEBUG)
    [assembly: AssemblyConfiguration(&quot;Debug&quot;)]
    [assembly: AssemblyProduct(&quot;Example Assembly (Debug)&quot;)]
#else
    [assembly: AssemblyConfiguration(&quot;Release&quot;)]
    [assembly: AssemblyProduct(&quot;Example Assembly (Release)&quot;)]
#endif</pre>
<p>Here I&#8217;m using <a href="http://msdn.microsoft.com/en-us/library/system.reflection.assemblyproductattribute.aspx"><strong>AssemblyProduct</strong> </a>to show the version as this information is shown in Details tab of the file&#8217;s properties in Windows:</p>
<p><a href="http://www.novolocus.com/wp-content/uploads/2012/03/File-Properties.png"><img class="aligncenter size-medium wp-image-2285" title="File Properties" src="http://www.novolocus.com/wp-content/uploads/2012/03/File-Properties-218x300.png" alt="" width="218" height="300" /></a></p>
<p>Okay, so we can have the solution compile differently for Release and Debug. What if we wanted to detect it for an assembly that we&#8217;d not compiled? Well, Scott Hanselman <a href="http://www.hanselman.com/blog/HowToProgrammaticallyDetectIfAnAssemblyIsCompiledInDebugOrReleaseMode.aspx">has answered this already</a>, but he doesn&#8217;t really define what is meant by a Debug build? Dave Black <a href="http://dave-black.blogspot.com/2011/12/how-to-tell-if-assembly-is-debug-or.html">goes into this in more detail </a>- but in short, does &#8216;Debug&#8217; mean you can attach a debugger, or that optimisation of the code is turned off? I agree with his opinion &#8211; most people are asking if the code is optimized.</p>
<p>So, based on their offerings, here is my code for determining if an assembly was build in &#8216;Debug&#8217; mode or not:</p>
<pre class="brush: csharp; title: ; notranslate">public static bool IsAssemblyDebug(Assembly assm)
{
    bool IsDebug = false;
    object[] attributes = assm.GetCustomAttributes(typeof(DebuggableAttribute), false);
    if (attributes.Length &gt; 0)
    {
        DebuggableAttribute d = (DebuggableAttribute)attributes[0];
        IsDebug = d.IsJITOptimizerDisabled;
    }
    return IsDebug;
}</pre>
<img src="http://feeds.feedburner.com/~r/novolocus/~4/d6HwY9HXcgU" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.novolocus.com/2012/03/06/know-whether-your-assembly-is-debug-or-release/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.novolocus.com/2012/03/06/know-whether-your-assembly-is-debug-or-release/</feedburner:origLink></item>
		<item>
		<title>Clearing the CA0068 Error in Code Analysis</title>
		<link>http://feedproxy.google.com/~r/novolocus/~3/nDeAIR5MzVE/</link>
		<comments>http://www.novolocus.com/2012/03/01/clearing-the-ca0068-error-in-code-analysis/#comments</comments>
		<pubDate>Thu, 01 Mar 2012 11:24:24 +0000</pubDate>
		<dc:creator>Andy</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Code Analysis]]></category>
		<category><![CDATA[pdb]]></category>

		<guid isPermaLink="false">http://www.novolocus.com/?p=2273</guid>
		<description><![CDATA[This error was appearing in the code analysis for one of my SharePoint projects. It reads: Warning 1 CA0068 : Debug information could not be found for target assembly &#8216;Something.exe&#8217;. For best analysis results, include the .pdb file with debug information for &#8230; <a href="http://www.novolocus.com/2012/03/01/clearing-the-ca0068-error-in-code-analysis/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>This error was appearing in the code analysis for one of my SharePoint projects. It reads:</p>
<blockquote><p>Warning 1 CA0068 : Debug information could not be found for target assembly &#8216;Something.exe&#8217;. For best analysis results, include the .pdb file with debug information for &#8216;Something.exe&#8217; in the same directory as the target assembly.</p></blockquote>
<p>Annoyingly, it didn&#8217;t seem to allow you to suppress it, and I was doing a Release build &#8211; so I didn&#8217;t expect to have a .pdb file. <span id="more-2273"></span></p>
<p>So, how to get rid of it? Step 1 &#8211; RTFM:</p>
<blockquote><p>Make sure that Debug info is either set to full for debug builds or to pdb-only for release builds. It should not be set to none.</p></blockquote>
<p>Excellent &#8211; but where is the setting? Well, in my project this seemed well hidden, but was actually under the &#8217;Advanced&#8230;&#8217; button:</p>
<p><a href="http://www.novolocus.com/wp-content/uploads/2012/03/debug-info.png"><img class="aligncenter size-medium wp-image-2274" title="debug info location" src="http://www.novolocus.com/wp-content/uploads/2012/03/debug-info-300x173.png" alt="" width="300" height="173" /></a></p>
<p>Apparently, the location of those settings can move, depending on project type.</p>
<img src="http://feeds.feedburner.com/~r/novolocus/~4/nDeAIR5MzVE" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.novolocus.com/2012/03/01/clearing-the-ca0068-error-in-code-analysis/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.novolocus.com/2012/03/01/clearing-the-ca0068-error-in-code-analysis/</feedburner:origLink></item>
		<item>
		<title>Check Permissions in JavaScript Client Object Model</title>
		<link>http://feedproxy.google.com/~r/novolocus/~3/dGTr9aNdBfA/</link>
		<comments>http://www.novolocus.com/2012/02/29/check-permissions-in-javascript-client-object-model/#comments</comments>
		<pubDate>Wed, 29 Feb 2012 10:02:22 +0000</pubDate>
		<dc:creator>Andy</dc:creator>
				<category><![CDATA[Development 2010]]></category>
		<category><![CDATA[clientobjectmodel]]></category>
		<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://www.novolocus.com/?p=2270</guid>
		<description><![CDATA[I had a need to check the rights a user had on a particular item in SharePoint. Unfortunately, this had to be done entirely client side. Naturally, I turned to the client object model &#8211; but it took a little &#8230; <a href="http://www.novolocus.com/2012/02/29/check-permissions-in-javascript-client-object-model/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I had a need to check the rights a user had on a particular item in SharePoint. Unfortunately, this had to be done entirely client side. Naturally, I turned to the client object model &#8211; but it took a little time to figure out.</p>
<p>I wanted to query for a particular item, some (though not all) of it&#8217;s properties, and I wanted to get it&#8217;s permissions. <a href="http://henrikfromsweden.blogspot.com/2010/11/code-example-for-enabledscript-elemnt.html">This post </a>by Henrik Andersson gave me a good clue, though it didn&#8217;t explicitly mention getting the properties. To get the item, with it&#8217;s properties and it&#8217;s permissions:</p>
<pre class="brush: csharp; title: ; notranslate">//var clientContext = new SP.ClientContext(.... ;
clientContext.load(listItem, 'EffectiveBasePermissions', 'ID', 'Title', 'Owner', 'Active', 'Modified', 'Editor');
clientContext.executeQueryAsync(Function.createDelegate(this, this.OnItemQueryCompleted), Function.createDelegate(this, this.OnItemQueryFailed)); </pre>
<p>That performs the query to get the item and permissions &#8211; but how do you check them? Well, you need to to use the <a href="http://msdn.microsoft.com/en-us/library/ee549165.aspx">SP.ListItem.get_effectiveBasePermissions()</a> method. (Note: there are <a href="http://msdn.microsoft.com/en-us/library/ee552795.aspx">SP.List.get_effectiveBasePermissions()</a> and <a href="http://msdn.microsoft.com/en-us/library/ee551324.aspx">SP.Web.get_effectiveBasePermissions()</a> methods too, for those tiers of the hierarchy).</p>
<pre class="brush: csharp; title: ; notranslate">function OnItemQueryCompleted(sender, args) {
	var perms = listItem.get_effectiveBasePermissions();

	if (perms.has(SP.PermissionKind.editListItems)) {
	      // ....
	}
}</pre>
<p>The permissions are retrieved into an <a href="http://msdn.microsoft.com/en-us/library/ee549745.aspx">SP.BasePermissions</a> object, which has the <strong>.has() </strong>method that you can use to check the permissions (returns true if the user does have that permission). The Permissions mask is defined by the values in the <a href="http://msdn.microsoft.com/en-us/library/ee556747.aspx">SP.PermissionKind</a> enumeration.</p>
<img src="http://feeds.feedburner.com/~r/novolocus/~4/dGTr9aNdBfA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.novolocus.com/2012/02/29/check-permissions-in-javascript-client-object-model/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		<feedburner:origLink>http://www.novolocus.com/2012/02/29/check-permissions-in-javascript-client-object-model/</feedburner:origLink></item>
		<item>
		<title>Handle Exceptions in Client Object Model callbacks</title>
		<link>http://feedproxy.google.com/~r/novolocus/~3/OwGy3BVzJM4/</link>
		<comments>http://www.novolocus.com/2012/02/27/handle-exceptions-in-client-object-model-callbacks/#comments</comments>
		<pubDate>Mon, 27 Feb 2012 10:02:10 +0000</pubDate>
		<dc:creator>Andy</dc:creator>
				<category><![CDATA[Development 2010]]></category>
		<category><![CDATA[clientobjectmodel]]></category>
		<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://www.novolocus.com/?p=2268</guid>
		<description><![CDATA[A note to myself, of something I found on MSDN &#8211; for the &#8216;failed&#8217; function on an asynchronous JavaScript call in the SharePoint Client Object Model: Note that these details are from the SP.ClientRequestFailedEventArgs class. There are other properties too.]]></description>
			<content:encoded><![CDATA[<p>A note to myself, of something I found on MSDN &#8211; for the &#8216;failed&#8217; function on an asynchronous JavaScript call in the SharePoint Client Object Model:</p>
<pre class="brush: csharp; title: ; notranslate">function OnItemQueryFailed(sender, args)
{
   alert('Error:\n' + args.get_message() + '\n' + args.get_stackTrace());
}</pre>
<p>Note that these details are from the <a href="http://msdn.microsoft.com/en-us/library/ee551330.aspx">SP.ClientRequestFailedEventArgs</a> class. There are other properties too.</p>
<img src="http://feeds.feedburner.com/~r/novolocus/~4/OwGy3BVzJM4" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.novolocus.com/2012/02/27/handle-exceptions-in-client-object-model-callbacks/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.novolocus.com/2012/02/27/handle-exceptions-in-client-object-model-callbacks/</feedburner:origLink></item>
		<item>
		<title>Working with the TaxonomyClientService: Part 2 – Get the TermSet (and understand it!)</title>
		<link>http://feedproxy.google.com/~r/novolocus/~3/GF3u93R1T4I/</link>
		<comments>http://www.novolocus.com/2012/02/09/working-with-the-taxonomyclientservice-part-2-get-the-termset-and-understand-it/#comments</comments>
		<pubDate>Thu, 09 Feb 2012 14:00:19 +0000</pubDate>
		<dc:creator>Andy</dc:creator>
				<category><![CDATA[Development 2010]]></category>
		<category><![CDATA[Taxonomy]]></category>
		<category><![CDATA[Web Services]]></category>

		<guid isPermaLink="false">http://www.novolocus.com/?p=2253</guid>
		<description><![CDATA[In Part 1 I looked at the structure of our Taxonomy field &#8211; which is in fact two fields. We also saw how the TaxonomyField definition has an array of properties related to it too. As a reminder, here&#8217;s a &#8230; <a href="http://www.novolocus.com/2012/02/09/working-with-the-taxonomyclientservice-part-2-get-the-termset-and-understand-it/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>In <a href="http://www.novolocus.com/2012/02/06/working-with-the-taxonomyclientservice-part-1-what-fields-are-there/">Part 1</a> I looked at the structure of our Taxonomy field &#8211; which is in fact two fields. We also saw how the TaxonomyField definition has an array of properties related to it too. As a reminder, here&#8217;s a screenshot of the XML for it:</p>
<p><a href="http://www.novolocus.com/wp-content/uploads/2012/01/TaxonomyField-Definition-in-CAML.png"><img class="alignnone size-medium wp-image-2249" title="TaxonomyField Definition in CAML" src="http://www.novolocus.com/wp-content/uploads/2012/01/TaxonomyField-Definition-in-CAML-300x133.png" alt="" width="300" height="133" /></a></p>
<p>These properties are quite important, as they tell us what we need to know to get the correct TermSet for our field.<span id="more-2253"></span></p>
<p>If you look in the properties you&#8217;ll see:</p>
<ul>
<li><strong>SspId</strong> &#8211; The ID of the Managed Metadata Service containing the TermSet for this field. This ID is also sometimes referred to as the TermStore ID.</li>
<li><strong>TermSetId</strong> - The ID of the TermSet for this field.</li>
</ul>
<p><a href="http://www.novolocus.com/wp-content/uploads/2012/01/Properties.png"><img class="alignnone size-medium wp-image-2254" title="Properties" src="http://www.novolocus.com/wp-content/uploads/2012/01/Properties-300x40.png" alt="" width="300" height="40" /></a></p>
<p>With this information we can use the <a href="http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.taxonomy.webservices.taxonomyclientservice.gettermsets.aspx"><strong>GetTermSets</strong> </a>method of the <strong>TaxonomyClientService</strong>. (The code below is based on &#8220;<a href="http://sharepointblog.virtosoftware.com/blogs/virtoteam/archive/2011/04/29/working-with-the-managed-metadata-service-remotely.aspx">Working with the Managed Metadata Service Remotely</a>&#8221; by Virtosoft.</p>
<pre class="brush: csharp; title: ; notranslate">string clientTimestamps = string.Format(&quot;&lt;timeStamp&gt;{0}&lt;/timeStamp&gt;&quot;, clientTime);
string clientVersion = &quot;&lt;version&gt;1&lt;/version&gt;&quot;;
string termStoreIds = string.Format(&quot;&lt;termStoreId&gt;{0}&lt;/termStoreId&gt;&quot;, termStoreId.ToString(&quot;D&quot;));
string termSetIds = string.Format(&quot;&lt;termSetId&gt;{0}&lt;/termSetId&gt;&quot;, termSetId.ToString(&quot;D&quot;));
string serverTermSetTimestampXml;
string result = _wssTax.GetTermSets(termStoreIds, termSetIds, 1033, clientTimestamps, clientVersion, out serverTermSetTimestampXml);</pre>
<p>So, there are a lot of parameters to that call &#8211; I&#8217;ll deal with them in<a href="http://www.novolocus.com/2012/04/26/working-with-the-taxonomyclientservice-part-3-caching/"> part 3</a>, which will be about caching. You&#8217;ll note that you can retrieve multiple termsets from multiple termstores &#8211; I think. I&#8217;ve not tried it (I&#8217;d rather make several calls and keep things simple).</p>
<p>Let&#8217;s look on what we get back from the service:</p>
<p><a href="http://www.novolocus.com/wp-content/uploads/2012/02/Results-of-GetTermSets.png"><img class="alignnone size-medium wp-image-2256" title="Results of GetTermSets" src="http://www.novolocus.com/wp-content/uploads/2012/02/Results-of-GetTermSets-300x161.png" alt="" width="300" height="161" /></a></p>
<p>Nice. So much for XML being human readable. So what&#8217;s this about?</p>
<p>First off, notice that there&#8217;s no nesting. All Terms are returned in a flat list:</p>
<p><a href="http://www.novolocus.com/wp-content/uploads/2012/02/Term-in-Results.png"><img class="alignnone size-medium wp-image-2257" title="Term in Results" src="http://www.novolocus.com/wp-content/uploads/2012/02/Term-in-Results-300x30.png" alt="" width="300" height="30" /></a></p>
<p>The elements of the terms are:</p>
<ul>
<li><strong>TS</strong> &#8211; Term Set</li>
<li><strong>T</strong> &#8211; The Term.</li>
<li><strong>LS</strong> &#8211; Label Set</li>
<li><strong>TL</strong> &#8211; Term Label. Potentially a Term can have several labels, for different Languages</li>
<li><strong>TMS</strong> &#8211; More Term Set Information</li>
<li><strong>TM</strong> &#8211; Term Information</li>
<li><strong>TD</strong> &#8211; Term Description</li>
</ul>
<p>The attributes are all numbered, which is really helpful. What do they mean?</p>
<ul>
<li><strong>a9</strong> &#8211; Term ID or TermSet ID</li>
<li><strong>a11</strong> &#8211; TermSet Description</li>
<li><strong>a12</strong> &#8211; Term Set Name the Term belongs to</li>
<li><strong>a16</strong> &#8211; Submission Policy (Is the termset open or closed)</li>
<li><strong>a17</strong> &#8211; Term is Enabled (can be used for tagging)</li>
<li><strong>a21</strong> &#8211; (boolean) False if the term is not deprecated</li>
<li><strong>a24</strong> &#8211; Term Set ID the Term belongs to</li>
<li><strong>a25</strong> &#8211; Parent Term ID</li>
<li><strong>a31</strong> &#8211; (boolean) Not sure, I think this is true if it&#8217;s the default term label?</li>
<li><strong>a32</strong> &#8211; Label Text</li>
<li><strong>a40</strong> &#8211; Parent Term Name</li>
<li><strong>a45</strong> &#8211; A semicolon separated list of the IDs of the Terms to the current term&#8217;s location in the taxonomy. (I.e. its path!)</li>
<li><strong>a61</strong> &#8211; (integer) ?</li>
<li><strong>a67</strong> &#8211; ?</li>
<li><strong>a68</strong> &#8211; TermSet contact email</li>
</ul>
<p>Nice and simple, eh?</p>
<p>Still, using this information you can determine the structure of the termset. In <a href="http://www.novolocus.com/2012/04/26/working-with-the-taxonomyclientservice-part-3-caching/">Part 3</a>, we&#8217;ll look at caching.</p>
<img src="http://feeds.feedburner.com/~r/novolocus/~4/GF3u93R1T4I" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.novolocus.com/2012/02/09/working-with-the-taxonomyclientservice-part-2-get-the-termset-and-understand-it/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		<feedburner:origLink>http://www.novolocus.com/2012/02/09/working-with-the-taxonomyclientservice-part-2-get-the-termset-and-understand-it/</feedburner:origLink></item>
		<item>
		<title>Working with the TaxonomyClientService: Part 1 – What fields are there?</title>
		<link>http://feedproxy.google.com/~r/novolocus/~3/O2Q2cF6TgN8/</link>
		<comments>http://www.novolocus.com/2012/02/06/working-with-the-taxonomyclientservice-part-1-what-fields-are-there/#comments</comments>
		<pubDate>Mon, 06 Feb 2012 14:00:37 +0000</pubDate>
		<dc:creator>Andy</dc:creator>
				<category><![CDATA[Development 2010]]></category>
		<category><![CDATA[Taxonomy]]></category>
		<category><![CDATA[Web Services]]></category>

		<guid isPermaLink="false">http://www.novolocus.com/?p=2248</guid>
		<description><![CDATA[I have been working on an integration that needs to read terms from SharePoint&#8217;s Managed Metadata service, for a particular field, and then populate that field with those values. All this has to be done via SharePoint&#8217;s web services &#8211; &#8230; <a href="http://www.novolocus.com/2012/02/06/working-with-the-taxonomyclientservice-part-1-what-fields-are-there/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I have been working on an integration that needs to read terms from SharePoint&#8217;s Managed Metadata service, for a particular field, and then populate that field with those values. All this has to be done via SharePoint&#8217;s web services &#8211; so the relevant ones here are the <strong><a href="http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.taxonomy.webservices.taxonomyclientservice.aspx">TaxonomyClientService</a>,</strong> and <strong><a href="http://msdn.microsoft.com/en-us/library/ie/websvclists.lists.aspx">Lists </a></strong>web service.</p>
<p>This has proved particularly bloody hard.<span id="more-2248"></span></p>
<p>To start with, let&#8217;s look at what fields I needed to deal with. When you add a Taxonomy column to a list, it actually adds two columns.</p>
<p>The first is your &#8216;display&#8217; column, and this can actually be one of two types &#8211; <a href="http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.taxonomy.taxonomyfield.aspx">TaxonomyFieldType </a>or TaxonomyFieldTypeMulti. As the name suggests, these are for single select and multi-select respectively.</p>
<p><a href="http://www.novolocus.com/wp-content/uploads/2012/01/TaxonomyField-Definition-in-CAML.png"><img class="alignnone size-large wp-image-2249" title="TaxonomyField Definition in CAML" src="http://www.novolocus.com/wp-content/uploads/2012/01/TaxonomyField-Definition-in-CAML-1024x454.png" alt="" width="584" height="258" /></a></p>
<p>The second column is a hidden field of the &#8216;Notes&#8217; type. This stores your actual data, it appears, though quite why still mystifies me a bit (more on that later).</p>
<p><a href="http://www.novolocus.com/wp-content/uploads/2012/01/Hidden-Field-Definition-in-CAML.png"><img class="alignnone size-large wp-image-2250" title="Hidden Field Definition in CAML" src="http://www.novolocus.com/wp-content/uploads/2012/01/Hidden-Field-Definition-in-CAML-1024x24.png" alt="" width="584" height="13" /></a></p>
<p>Anyway, there are two columns. As you can see from the screenshots above, the Taxonomy column contains an array of customisation properties.</p>
<p>So, how are these two fields related? Well, not using the &#8216;RelatedField&#8217; attribute (too obvious), and when I did a bit of a search I kept finding blog posts saying that I would have one field with the name I gave it, and another field with the same number but ending with an additional &#8220;TaxHTField0&#8243; text. This was not the behaviour that I saw; it might have changed in a service pack.</p>
<p>On my system, the second (Notes) field seemed to have a GUID-like name. It looked mostly hexidecimal, but was often prefixed by a couple of non-hex characters. At first I thought that this might be the reference between the two fields.</p>
<p>However, the relationship is in fact one of the array of properties on the field:</p>
<p><a href="http://www.novolocus.com/wp-content/uploads/2012/01/TextField-Property.png"><img class="alignnone size-medium wp-image-2251" title="TextField Property" src="http://www.novolocus.com/wp-content/uploads/2012/01/TextField-Property-300x15.png" alt="" width="300" height="15" /></a></p>
<p>The TextField property contains the ID of the Notes Field. Great, that&#8217;s nice and simple.</p>
<p>So, in summary, the relationship between the TaxonomyField and Notes field is held in the TextField property in the array of properties of the TaxonomyField. The value is the ID of the Notes field. You can get this information a variety of ways, but I used the GetListContentType method of the Lists web service.</p>
<p>In <a href="http://www.novolocus.com/2012/02/09/working-with-the-taxonomyclientservice-part-2-get-the-termset-and-understand-it/">Part 2</a> we&#8217;ll look at getting and interpreting the TermSet for our field.</p>
<img src="http://feeds.feedburner.com/~r/novolocus/~4/O2Q2cF6TgN8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.novolocus.com/2012/02/06/working-with-the-taxonomyclientservice-part-1-what-fields-are-there/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.novolocus.com/2012/02/06/working-with-the-taxonomyclientservice-part-1-what-fields-are-there/</feedburner:origLink></item>
		<item>
		<title>SafeControls Entries in Manifest can be changed during deployment</title>
		<link>http://feedproxy.google.com/~r/novolocus/~3/-tgs898l6rI/</link>
		<comments>http://www.novolocus.com/2012/01/16/safecontrols-entries-in-manifest-can-be-changed-during-deployment/#comments</comments>
		<pubDate>Mon, 16 Jan 2012 17:20:42 +0000</pubDate>
		<dc:creator>Andy</dc:creator>
				<category><![CDATA[Development 2010]]></category>
		<category><![CDATA[Assemblies]]></category>
		<category><![CDATA[SPWebConfigModification]]></category>
		<category><![CDATA[Web Parts]]></category>

		<guid isPermaLink="false">http://www.novolocus.com/?p=2234</guid>
		<description><![CDATA[I had a slightly unusual situation. We&#8217;ve a customer who has using the Telerik RadEditor version 4.5.6 for SharePoint 2007. They&#8217;re upgrading to SharePoint 2010, and want their existing content to continue to work. They&#8217;ve using the Telerik RadEditor web part &#8230; <a href="http://www.novolocus.com/2012/01/16/safecontrols-entries-in-manifest-can-be-changed-during-deployment/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I had a slightly unusual situation. We&#8217;ve a customer who has using the <a href="http://www.telerik.com/products/sharepoint/overview.aspx">Telerik RadEditor </a>version 4.5.6 for SharePoint 2007. They&#8217;re upgrading to SharePoint 2010, and want their existing content to continue to work.</p>
<p>They&#8217;ve using the Telerik RadEditor web part quite a lot, so we had to keep that working. We&#8217;ve put in Assembly Binding Redirects using an <strong>SPWebConfigModification</strong> (more on that in a later post).</p>
<p>However, we also needed to put in the <a href="http://msdn.microsoft.com/en-us/library/ms451053.aspx">SafeControl </a>entry for the <strong>old</strong> assembly. <span id="more-2234"></span>Maurice Prather <a href="http://www.bluedoglimited.com/SharePointThoughts/Lists/Posts/Post.aspx?ID=311">discusses this here</a>. The short of it is:</p>
<blockquote>
<div>What happens to your Web Part when it&#8217;s redirected to version Y?</div>
<ol>
<li>On <em><strong>first </strong></em>render of a redirected Web Part instance (this is a KEY thing to remember), if the SafeControl for version X exists, an attempt to load the Web Part is made.</li>
<li>The .NET framework kicks in and redirect to version Y is successfully made.</li>
<li>SharePoint notices that the Web Part type guid (nothing we the Web Part developers can explicitly control) has changed and saves the new type id back to the database.</li>
<li>From that point forward, the next time the Web Part is loaded, the call is made directly for version Y.</li>
</ol>
<p>Take a look at step #3.  This is key.  The database actually contains a reference to your web part in a form of a guid.  The guid is a calculated value that allows the SafeMode parser to rapidly associate the serialized form with a live class type.  The important thing to remember is that this reference lives on a per-page reference (i.e. page ABC has reference to web part types M, Q, V).</p>
<p>Why is this important?  Until all instances of Web Part version X have been rendered, you cannot remove the SafeControl reference to version X unless you want bindingRedirect to fail.</p></blockquote>
<p>Okay, fine. That makes sense, and I don&#8217;t have a problem marking a web part that we&#8217;ve been using for ages as safe, even if it will ultimately be updated in all instances by the redirection.</p>
<p>So, I put a new SafeControl entry into on the SharePoint Project Items of my solution.</p>
<p><em>(Please note: below I&#8217;ve used an assembly called &#8216;MyAssembly&#8217;. I&#8217;ve changed the name from the real assembly &#8216;cos I&#8217;m not sure I&#8217;m allowed to talk about it. But I&#8217;m showing the behaviour I saw).</em></p>
<p><a href="http://www.novolocus.com/wp-content/uploads/2012/01/Safe-Control-Entry-Dialog-Box.png"><img class="alignnone size-medium wp-image-2237" title="Safe Control Entry Dialog Box" src="http://www.novolocus.com/wp-content/uploads/2012/01/Safe-Control-Entry-Dialog-Box-300x143.png" alt="" width="300" height="143" /></a></p>
<p>This was then included in my Manifest:</p>
<p><a href="http://www.novolocus.com/wp-content/uploads/2012/01/Correct-In-Manifest.png"><img class="alignnone size-large wp-image-2235" title="Correct In Manifest" src="http://www.novolocus.com/wp-content/uploads/2012/01/Correct-In-Manifest-1024x149.png" alt="" width="584" height="84" /></a></p>
<p>However, when I went and checked the web.config I saw:</p>
<p><a href="http://www.novolocus.com/wp-content/uploads/2012/01/incorrect-web-config-entry.png"><img class="alignnone size-full wp-image-2238" title="incorrect web config entry" src="http://www.novolocus.com/wp-content/uploads/2012/01/incorrect-web-config-entry.png" alt="" width="747" height="56" /></a></p>
<p>WTF? As best as I can determine, the assembly information in my SafeControls entry in my solution&#8217;s manifest has been <em>ignored</em>. The entry in the manifest lives within a particular Assembly element, so presumably SharePoint itself chooses to read the information from the assembly, rather than the manifest! (Why ask for the information then?)</p>
<p>Consequently, I found that the best option I had was to write an <a href="http://msdn.microsoft.com/en-us/library/bb861909.aspx"><strong>SPWebConfigModification</strong> </a>to add my Safe Control entry. And that worked nicely.</p>
<p><strong>Conclusion</strong>: If your WSP doesn&#8217;t contain the assembly you&#8217;re trying to create a SafeControl entry for, you&#8217;ll probably need to use an <strong>SPWebConfigModification</strong>. That seems a shame, given that Visual Studio 2010 appears to let you create other Safe Control entries, and puts them into the manifest correctly.</p>
<img src="http://feeds.feedburner.com/~r/novolocus/~4/-tgs898l6rI" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.novolocus.com/2012/01/16/safecontrols-entries-in-manifest-can-be-changed-during-deployment/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.novolocus.com/2012/01/16/safecontrols-entries-in-manifest-can-be-changed-during-deployment/</feedburner:origLink></item>
		<item>
		<title>Attaching Visual Studio 2010 to Outlook 2010 plugin for Debugging</title>
		<link>http://feedproxy.google.com/~r/novolocus/~3/q5KGnOYsaW0/</link>
		<comments>http://www.novolocus.com/2012/01/12/attaching-visual-studio-2010-to-outlook-2010-plugin-for-debugging/#comments</comments>
		<pubDate>Thu, 12 Jan 2012 10:47:49 +0000</pubDate>
		<dc:creator>Andy</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Outlook]]></category>
		<category><![CDATA[Visual Studio]]></category>

		<guid isPermaLink="false">http://www.novolocus.com/?p=2229</guid>
		<description><![CDATA[I was trying to attach a debugger to an Outlook plugin I was working on. It was originally written for Outlook 2003, but has been progressively upgraded to 2010. However, I couldn&#8217;t breakpoint my code, or rather, the breakpoints weren&#8217;t &#8230; <a href="http://www.novolocus.com/2012/01/12/attaching-visual-studio-2010-to-outlook-2010-plugin-for-debugging/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I was trying to attach a debugger to an Outlook plugin I was working on. It was originally written for Outlook 2003, but has been progressively upgraded to 2010. However, I couldn&#8217;t breakpoint my code, or rather, the breakpoints weren&#8217;t being hit.</p>
<p>Found <a href="http://stackoverflow.com/questions/3198262/difficulty-starting-vs-2010-debugger-attached-to-outlook-to-debug-plugin">the answer on Stack Overflow</a>:</p>
<blockquote><p>So it turns out that Outlook doesn&#8217;t load the CLR on startup (it must be loaded shortly thereafter when it becomes necessary), which apparently confuses the VS debugger and causes it to only debug native code. To force it to load the CLR immediately, create an OUTLOOK.EXE.config file in the same folder with:</p></blockquote>
<p><code>&lt;configuration&gt; &lt;startup&gt; &lt;supportedRuntime version="v2.0.50727"/&gt;  &lt;/startup&gt;&lt;/configuration&gt;</code></p>
<blockquote><p>which is from this <a href="http://www.analogousmember.com/archives/000394.html">blog post</a>. Then, even when VS starts attached, it will debug CLR code</p></blockquote>
<img src="http://feeds.feedburner.com/~r/novolocus/~4/q5KGnOYsaW0" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.novolocus.com/2012/01/12/attaching-visual-studio-2010-to-outlook-2010-plugin-for-debugging/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.novolocus.com/2012/01/12/attaching-visual-studio-2010-to-outlook-2010-plugin-for-debugging/</feedburner:origLink></item>
	</channel>
</rss>

