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

<channel>
	<title>Ideas For Free &#187; Development</title>
	<atom:link href="http://blog.libinuko.com/tag/development/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.libinuko.com</link>
	<description>Only freedom will grow our ideas</description>
	<lastBuildDate>Sun, 18 Dec 2011 04:51:16 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Troubleshoot: SPPropertyBag can not deserialize complex type.</title>
		<link>http://blog.libinuko.com/2009/10/11/troubleshoot-sppropertybag-can-not-deserialize-complex-type/</link>
		<comments>http://blog.libinuko.com/2009/10/11/troubleshoot-sppropertybag-can-not-deserialize-complex-type/#comments</comments>
		<pubDate>Sun, 11 Oct 2009 05:13:41 +0000</pubDate>
		<dc:creator>cakriwut</dc:creator>
				<category><![CDATA[SharePoint 2007]]></category>
		<category><![CDATA[Troubleshoot]]></category>
		<category><![CDATA[Development]]></category>

		<guid isPermaLink="false">http://blog.libinuko.com/2009/10/11/troubleshoot-sppropertybag-can-not-deserialize-complex-type/</guid>
		<description><![CDATA[&#160; English: In SharePoint, there is SPPropertyBag which can stores arbitrary key-and-value pairs into configuration database. And this is very good location compared with web.config. Moreover we can also create our custom class from SPPersistedObject to persist it state in a permanent store and retrieve it for later usage. (see MSDN refence SPPersistedObject) But don’t be so happy [...] <a href="http://blog.libinuko.com/2009/10/11/troubleshoot-sppropertybag-can-not-deserialize-complex-type/">[read more...]</a>]]></description>
			<content:encoded><![CDATA[<!-- google_ad_section_start --><p>&#160;
</p>
<p>English:</p>
<p>In SharePoint, there is SPPropertyBag which can stores arbitrary key-and-value pairs into configuration database. And this is very good location compared with web.config. Moreover we can also create our custom class from SPPersistedObject to persist it state in a permanent store and retrieve it for later usage. (see MSDN refence <a href="http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.administration.sppersistedobject.aspx">SPPersistedObject</a>)</p>
<p>But don’t be so happy – the SPPropertyBag can only store primitive types such as strings, integers, and GUID; and collection of above. The main keyword to understand is SPPropertyBag can only store primitives type and not arbitrary key-and-value pairs.</p>
<p>When you try to store complex object, you&#8217;ll unstablize configuration DB. And most of the time, you will not be able to install WSP, or perform anything related with SPPropertyBag operation. For example the timer job will stops to work, any component that reads SPPropertyBag will suddenly stuck. All because SharePoint will try to retrieve any persisted object from configuration DB and it fails. It will then show you and error message like this,</p>
<blockquote><p>The platform does not know how to deserialize an object of type [TYPE]. The platform can deserialize primitive types such as strings, integers and GUID; other SPPersistedObjects or SPAutoserializingObjects or collections of any of the above. (..more..)</p>
</blockquote>
<p>The visual error will be something like this,</p>
<p><a href="http://blog.libinuko.com/wp-content/uploads/2009/10/SPBag1.gif"><img style="border-bottom: 0px;border-left: 0px;border-top: 0px;border-right: 0px" border="0" alt="SPBag1" src="http://blog.libinuko.com/wp-content/uploads/2009/10/SPBag1_thumb.gif" width="684" height="363" /></a> </p>
<p>&#160;</p>
<p>So how to troubleshoot this issue?</p>
<blockquote><p>IMPORTANT!&#160; <br />1. Please backup configuration DB before proceeding with following procedure.      <br />2. This procedure will modify configuration DB directly , and is un-supported by Microsoft.</p>
</blockquote>
<p>TROUBLESHOOT.</p>
<p>1. Remove offending assembly from GAC (C:\Windows\Assembly) store.</p>
<p>2. Open Query Manager in SQL Management Studio, and connect to SharePoint content DB. Check that you have all reference to the offending property bag.</p>
<p><a href="http://blog.libinuko.com/wp-content/uploads/2009/10/SPBag2.gif"><img style="border-bottom: 0px;border-left: 0px;border-top: 0px;border-right: 0px" border="0" alt="SPBag2" src="http://blog.libinuko.com/wp-content/uploads/2009/10/SPBag2_thumb.gif" width="682" height="358" /></a> </p>
<p>3.&#160; Offending property bag can be found in “Properties” field of Objects table. If you dig into the content you will find something like</p>
</p>
<blockquote><p>&lt;object type=……&gt;     <br />…&lt;fld type=”[YOUR TYPE]”&gt;&lt;/fld&gt;..      <br />&lt;/object&gt;</p>
</blockquote>
<p>where [YOUR TYPE] is the one causing problem. Once you have sure that you have all rows selected, then you can do clean up.</p>
<p>4. Replace SELECT [Fields] statement with DELETE statement.</p>
<p><a href="http://blog.libinuko.com/wp-content/uploads/2009/10/SPBag3.gif"><img style="border-bottom: 0px;border-left: 0px;border-top: 0px;border-right: 0px" border="0" alt="SPBag3" src="http://blog.libinuko.com/wp-content/uploads/2009/10/SPBag3_thumb.gif" width="658" height="278" /></a> </p>
<p>And voila, I have saved you from big trouble.</p>
<!-- google_ad_section_end -->]]></content:encoded>
			<wfw:commentRss>http://blog.libinuko.com/2009/10/11/troubleshoot-sppropertybag-can-not-deserialize-complex-type/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Howto: Use lambda expression in SharePoint Object Model &#8211; Working with WebApplication</title>
		<link>http://blog.libinuko.com/2009/05/17/howto-use-lambda-expression-in-sharepoint-object-model-working-with-webapplication/</link>
		<comments>http://blog.libinuko.com/2009/05/17/howto-use-lambda-expression-in-sharepoint-object-model-working-with-webapplication/#comments</comments>
		<pubDate>Sat, 16 May 2009 16:30:00 +0000</pubDate>
		<dc:creator>cakriwut</dc:creator>
				<category><![CDATA[SharePoint 2007]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Lambda]]></category>
		<category><![CDATA[SharePoint]]></category>

		<guid isPermaLink="false">http://blog.libinuko.com/2009/05/17/howto-use-lambda-expression-in-sharepoint-object-model-working-with-webapplication/</guid>
		<description><![CDATA[English Before you continue reading this post, I hope you have read the basic task to start using lambda expression in SOM here. A. Find existing job definition, named “Change Log” SPWebApplication spWebApplication = SPContext.Current.Site.WebApplication; var jobs = spWebApplication.JobDefinitions.Where(x =&#62; x.Title == &#34;Change Log&#34;); foreach(SPJobDefinition job in [...] <a href="http://blog.libinuko.com/2009/05/17/howto-use-lambda-expression-in-sharepoint-object-model-working-with-webapplication/">[read more...]</a>]]></description>
			<content:encoded><![CDATA[<!-- google_ad_section_start --><p>English</p>
<p>Before you continue reading this post, I hope you have read the basic task to start using lambda expression in SOM <a href="http://blog.libinuko.com/2009/04/21/howto-use-lambda-expression-in-sharepoint-object-model/">here</a>.</p>
<p>A. Find existing job definition, named “Change Log”</p>
<blockquote><p>SPWebApplication spWebApplication = SPContext.Current.Site.WebApplication;      <br />var jobs = spWebApplication.JobDefinitions.Where(x =&gt; x.Title == &quot;Change Log&quot;);       <br />foreach(SPJobDefinition job in jobs)       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Console.WriteLine(job.Id);</p>
</blockquote>
<p>B. Find existing custom job definition MyCustomJobDefinition, named “My Custom Job”</p>
<blockquote><p>SPWebApplication spWebApplication = SPContext.Current.Site.WebApplication;      <br />var jobs = spWebApplication.JobDefinitions.<strong>OfType&lt;MyCustomJobDefinition&gt;()</strong>.Where(x =&gt; x.Title == &quot;My Custom Job&quot;);       <br />foreach(SPJobDefinition job in jobs)       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Console.WriteLine(job.Id);</p>
</blockquote>
<p>C. Find site collection from “STS” template</p>
<blockquote><p>SPWebApplication webApplication = SPContext.Current.Site.WebApplication;</p>
<p>var allSPSite = webApplication.Sites.<strong>OfType&lt;SPSite&gt;()</strong>.Where(s =&gt; s.RootWeb.WebTemplate.Equals(&quot;STS&quot;, StringComparison.InvariantCultureIgnoreCase));</p>
<p>foreach(SPSite spSite in allSPSite)</p>
<p>{</p>
<p>&#160;&#160;&#160;&#160;&#160; // operation in the SPSite</p>
<p>}</p>
</blockquote>
<p>D. Find All RootWeb (of Site collection)</p>
<blockquote><p>SPWebApplication spWebApplication = SPContext.Current.Site.webApplication;     <br />var rootWebs= spWebApplication.Sites.OfType&lt;SPSite&gt;().Select ( s =&gt; s.RootWeb );       <br />foreach (SPWeb spWeb in rootWebs)      <br />{      <br />&#160;&#160; // Do your task here      <br />}</p>
</blockquote>
<p>E. Find if Site Collection with RootWeb contains list named “Sample List”</p>
<blockquote><p>SPWebApplication spWebApplication = SPContext.Current.Site.webApplication;     <br />var sites = spWebApplication.Sites.OfType&lt;SPSite&gt;().Where(       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; s =&gt; s.RootWeb.Lists.OfType&lt;SPList&gt;().Where(      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; l =&gt; l.Title.Equals(&quot;Sample List&quot;,StringComparison.InvariantCultureIgnoreCase)).Count() &gt; 0);       <br />foreach (SPSite spSite in sites)      <br />{      <br />&#160;&#160; // Do your task here      <br />}</p>
</blockquote>
<p>F. Find if RootWeb which contains list named “Sample List”</p>
<blockquote><p>SPWebApplication spWebApplication = SPContext.Current.Site.webApplication;</p>
<p>var rootWebs = spWebApplication.Sites.OfType&lt;SPSite&gt;().Select(s =&gt; s.RootWeb).Where(     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; r =&gt; r.Lists.OfType&lt;SPList&gt;().Where(       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; l =&gt; l.Title.Equals(&quot;Sample List&quot;,StringComparison.InvariantCultureIgnoreCase)).Count() &gt; 0);</p>
<p>foreach (SPWeb spWeb in rootWebs)     <br />{      <br />&#160;&#160; // Do your task here      <br />}</p>
</blockquote>
<!-- google_ad_section_end -->]]></content:encoded>
			<wfw:commentRss>http://blog.libinuko.com/2009/05/17/howto-use-lambda-expression-in-sharepoint-object-model-working-with-webapplication/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Howto: Use lambda expression in SharePoint Object model</title>
		<link>http://blog.libinuko.com/2009/04/21/howto-use-lambda-expression-in-sharepoint-object-model/</link>
		<comments>http://blog.libinuko.com/2009/04/21/howto-use-lambda-expression-in-sharepoint-object-model/#comments</comments>
		<pubDate>Tue, 21 Apr 2009 14:51:00 +0000</pubDate>
		<dc:creator>cakriwut</dc:creator>
				<category><![CDATA[SharePoint 2007]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Lambda]]></category>
		<category><![CDATA[SharePoint]]></category>

		<guid isPermaLink="false">http://blog.libinuko.com/2009/04/21/howto-use-lambda-expression-in-sharepoint-object-model/</guid>
		<description><![CDATA[English Lambda expression has been introduced since .NET framework 3.5, it is an anonymous function that can contain statement and expression. For more understanding on lambda expression you can read directly in MSDN page here. I will assume that you have read the topic and you can remember the lambda simply as: (input parameters ) =&#62; operation We [...] <a href="http://blog.libinuko.com/2009/04/21/howto-use-lambda-expression-in-sharepoint-object-model/">[read more...]</a>]]></description>
			<content:encoded><![CDATA[<!-- google_ad_section_start --><p>English</p>
<p>Lambda expression has been introduced since .NET framework 3.5, it is an anonymous function that can contain statement and expression. For more understanding on lambda expression you can read directly in <a href="http://msdn.microsoft.com/en-us/library/bb397687.aspx">MSDN page here</a>. I will assume that you have read the topic and you can remember the lambda simply as:</p>
<blockquote><p>(input parameters ) =&gt; operation</p>
</blockquote>
<p>We will start with very basic operation of using lambda expression in SOM, and I hope you’ll find your path for more complex one. <em>(note some code may not be efficient, for the clarity purpose)</em></p>
<p>A.&#160; Start with OfType&lt;TResult&gt;() function to get IEnumerable that implement query pattern.</p>
<p>Example: </p>
<p>Originally to browse to all Site collection in WebApplication we will write,</p>
<blockquote><p>SPWebApplication webApplication = SPContext.Current.Site.WebApplication;</p>
<p><strong>SPSiteCollection allSPSite = webApplication.Sites;</strong></p>
<p><strong>foreach(SPSite spSite in allSPSite)</strong></p>
<p><strong>{</strong></p>
<p><strong>&#160;&#160;&#160;&#160;&#160; // operation in the SPSite</strong></p>
<p><strong>}</strong></p>
</blockquote>
<p>the equivalent for our lambda starter is,</p>
<blockquote><p>SPWebApplication webApplication = SPContext.Current.Site.WebApplication;</p>
<p><strong>var allSPSite = webApplication.Sites.OfType&lt;SPSite&gt;();</strong></p>
<p><strong>foreach(SPSite spSite in allSPSite)</strong></p>
<p><strong>{</strong></p>
<p><strong>&#160;&#160;&#160;&#160;&#160; // operation in the SPSite</strong></p>
<p><strong>}</strong></p>
</blockquote>
<p>B. Use lambda expression in the IEnumerable</p>
<p>Example :</p>
<p>You need to list all Site collection which uses STS site template.</p>
<p>Originally you will write,</p>
<blockquote><p>SPWebApplication webApplication = SPContext.Current.Site.WebApplication;</p>
<p><strong>SPSiteCollection allSPSite = webApplication.Sites;</strong></p>
<p><strong>foreach(SPSite spSite in allSPSite)</strong></p>
<p><strong>{</strong></p>
<p><strong>&#160;&#160;&#160;&#160;&#160; if(spSite.RootWeb.WebTemplate.Equals(“STS”,StringComparison.InvariantCultureIgnoreCase))</strong></p>
<p><strong>&#160;&#160;&#160;&#160; {</strong></p>
<p><strong>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; // Do operation in selected site </strong></p>
<p><strong>&#160;&#160;&#160;&#160; }</strong></p>
<p><strong>}</strong></p>
</blockquote>
<p> the equivalent using lambda is,</p>
<blockquote><p>SPWebApplication webApplication = SPContext.Current.Site.WebApplication;</p>
<p><strong>var allSPSite = webApplication.Sites.OfType&lt;SPSite&gt;().Where(s =&gt; s.RootWeb.WebTemplate.Equals(&quot;STS&quot;, StringComparison.InvariantCultureIgnoreCase));</strong></p>
<p><strong>foreach(SPSite spSite in allSPSite)</strong></p>
<p><strong>{</strong></p>
<p><strong>&#160;&#160;&#160;&#160;&#160; // operation in the SPSite</strong></p>
<p><strong>}</strong></p>
</blockquote>
<p>Ok, now I believe you will get the idea of how to use lambda expression in SOM collection. In next posting, I’ll cover directly to the sample usage of the lambda.</p>
<!-- google_ad_section_end -->]]></content:encoded>
			<wfw:commentRss>http://blog.libinuko.com/2009/04/21/howto-use-lambda-expression-in-sharepoint-object-model/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

