<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>SocialSP</title>
	<atom:link href="http://socialsp.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://socialsp.com</link>
	<description>SharePoint 2010 development tips and tricks and Social features</description>
	<lastBuildDate>Tue, 06 Dec 2011 14:03:33 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='socialsp.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://0.gravatar.com/blavatar/879ceff91c16162aa22262ba137c3b9b?s=96&#038;d=http%3A%2F%2Fs2.wp.com%2Fi%2Fbuttonw-com.png</url>
		<title>SocialSP</title>
		<link>http://socialsp.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://socialsp.com/osd.xml" title="SocialSP" />
	<atom:link rel='hub' href='http://socialsp.com/?pushpress=hub'/>
		<item>
		<title>Last post&#8230;.</title>
		<link>http://socialsp.com/2011/07/26/last-post/</link>
		<comments>http://socialsp.com/2011/07/26/last-post/#comments</comments>
		<pubDate>Tue, 26 Jul 2011 12:46:26 +0000</pubDate>
		<dc:creator>anogueira</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://socialsp.com/?p=173</guid>
		<description><![CDATA[Hi, Unfortunately, I&#8217;ll no longer post on this blog. I&#8217;ve refocused my career on a different direction and I&#8217;m no longer working directly with SharePoint. I&#8217;ll leave the blog up and running for now since I still can help some &#8230; <a href="http://socialsp.com/2011/07/26/last-post/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=socialsp.com&amp;blog=10599735&amp;post=173&amp;subd=socialsp&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Hi,</p>
<p>Unfortunately, I&#8217;ll no longer post on this blog. I&#8217;ve refocused my career on a different direction and I&#8217;m no longer working directly with SharePoint. I&#8217;ll leave the blog up and running for now since I still can help some people with some SharePoint issues.</p>
<p>Yours,</p>
<p>Andy.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/socialsp.wordpress.com/173/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/socialsp.wordpress.com/173/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/socialsp.wordpress.com/173/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/socialsp.wordpress.com/173/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/socialsp.wordpress.com/173/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/socialsp.wordpress.com/173/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/socialsp.wordpress.com/173/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/socialsp.wordpress.com/173/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/socialsp.wordpress.com/173/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/socialsp.wordpress.com/173/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/socialsp.wordpress.com/173/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/socialsp.wordpress.com/173/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/socialsp.wordpress.com/173/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/socialsp.wordpress.com/173/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=socialsp.com&amp;blog=10599735&amp;post=173&amp;subd=socialsp&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://socialsp.com/2011/07/26/last-post/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/d923a9f76162684e4554196c103d1cf1?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Andy Nogueira</media:title>
		</media:content>
	</item>
		<item>
		<title>Force SharePoint 2010 Search Scope Update</title>
		<link>http://socialsp.com/2011/03/22/force-sharepoint-2010-search-scope-update/</link>
		<comments>http://socialsp.com/2011/03/22/force-sharepoint-2010-search-scope-update/#comments</comments>
		<pubDate>Tue, 22 Mar 2011 18:04:54 +0000</pubDate>
		<dc:creator>anogueira</dc:creator>
				<category><![CDATA[Configuration]]></category>
		<category><![CDATA[SharePoint]]></category>

		<guid isPermaLink="false">http://socialsp.com/?p=162</guid>
		<description><![CDATA[For those wondering how to force a scope update and not having to wait 14 minutes for each update, this can help. Go to Central Administration site Go to your Search Service Application (Manage Services -&#62; Search SA) On the &#8230; <a href="http://socialsp.com/2011/03/22/force-sharepoint-2010-search-scope-update/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=socialsp.com&amp;blog=10599735&amp;post=162&amp;subd=socialsp&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>For those wondering how to force a scope update and not having to wait 14 minutes for each update, this can help.</p>
<ul>
<li>
<div style="padding-left:30px;">Go to <strong>Central Administration </strong>site</div>
</li>
<li>
<div style="padding-left:30px;">Go to your<strong> Search Service Application </strong>(Manage Services -&gt; Search SA)</div>
</li>
<li>
<div style="padding-left:30px;">On the left hand side, click on<strong> Search Administration </strong>link under Administration</div>
</li>
<li>
<div style="padding-left:30px;">Unders System Status, look for an entry saying <strong>Scopes needing update </strong>and click on the <strong>Start Update Now</strong> link (see below)</div>
</li>
</ul>
<p><a href="http://socialsp.files.wordpress.com/2011/03/scope1.jpg"><img class="alignleft size-full wp-image-164" title="scope" src="http://socialsp.files.wordpress.com/2011/03/scope1.jpg?w=500&#038;h=319" alt="" width="500" height="319" /></a></p>
<p><a href="http://socialsp.files.wordpress.com/2011/03/scope.jpg"></a></p>
<p>Pretty straightforward !</p>
<p>Hope that helps !</p>
<p>Andy Nogueira.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/socialsp.wordpress.com/162/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/socialsp.wordpress.com/162/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/socialsp.wordpress.com/162/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/socialsp.wordpress.com/162/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/socialsp.wordpress.com/162/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/socialsp.wordpress.com/162/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/socialsp.wordpress.com/162/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/socialsp.wordpress.com/162/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/socialsp.wordpress.com/162/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/socialsp.wordpress.com/162/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/socialsp.wordpress.com/162/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/socialsp.wordpress.com/162/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/socialsp.wordpress.com/162/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/socialsp.wordpress.com/162/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=socialsp.com&amp;blog=10599735&amp;post=162&amp;subd=socialsp&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://socialsp.com/2011/03/22/force-sharepoint-2010-search-scope-update/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/d923a9f76162684e4554196c103d1cf1?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Andy Nogueira</media:title>
		</media:content>

		<media:content url="http://socialsp.files.wordpress.com/2011/03/scope1.jpg" medium="image">
			<media:title type="html">scope</media:title>
		</media:content>
	</item>
		<item>
		<title>Access Denied Messages when retrieving SharePoint User Profiles Count even running in Elevated code</title>
		<link>http://socialsp.com/2010/11/25/access-denied-messages-when-retrieving-sharepoint-user-profiles-count-even-running-in-elevated-code/</link>
		<comments>http://socialsp.com/2010/11/25/access-denied-messages-when-retrieving-sharepoint-user-profiles-count-even-running-in-elevated-code/#comments</comments>
		<pubDate>Thu, 25 Nov 2010 18:13:47 +0000</pubDate>
		<dc:creator>anogueira</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[SharePoint]]></category>
		<category><![CDATA[sharepoint 2010]]></category>
		<category><![CDATA[User Profiles]]></category>

		<guid isPermaLink="false">http://socialsp.com/?p=129</guid>
		<description><![CDATA[This is another tricky one. And I think I had this problem long time ago which I had this workaround but couldn&#8217;t remember about it until I&#8217;ve looked into an old code snippet. Here&#8217;s the scenario. You need to retrieve &#8230; <a href="http://socialsp.com/2010/11/25/access-denied-messages-when-retrieving-sharepoint-user-profiles-count-even-running-in-elevated-code/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=socialsp.com&amp;blog=10599735&amp;post=129&amp;subd=socialsp&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>This is another tricky one. And I think I had this problem long time ago which I had this workaround but couldn&#8217;t remember about it until I&#8217;ve looked into an old code snippet.</p>
<h3>Here&#8217;s the scenario.</h3>
<p>You need to retrieve the total number of user profiles in SharePoint. The API has a property for that in the UserProfileManager class. You could just write some code like this:</p>
<p><pre class="brush: csharp; highlight: [2];">

UserProfileManager profileManager = new UserProfileManager(serviceContext);
long ProfileCount = profileManager.Count;

</pre></p>
<p>But the problem is that in order to retrieve this you need to have admin privileges on the User Profile Service. So the logical way of doing this is to run the code with Elevated privileges and ensure the identity used by the application pool of your site has admin privileges on the User Profile service. So I&#8217;ve tried that using the code below:</p>
<p><pre class="brush: csharp;">

SPSite siteColl = SPContext.Current.Site;

try{
  SPSecurity.RunWithElevatedPrivileges(delegate()
  {
    using (SPSite ElevatedsiteColl = new SPSite(siteColl.ID))
    {
      SPServiceContext serviceContext = SPServiceContext.GetContext(ElevatedsiteColl);
    UserProfileManager profileManager = new UserProfileManager(serviceContext);
    ProfileCount = profileManager.Count;
    }
  });
}
catch (Exception ex)
{
  LogException(ex);
}

</pre></p>
<p>Testing the code running under an Admin account it was fine (because it was the same account used by the site&#8217;s application pool). But when I tested the code using a regular user this code should still run fine (because I was running it elevated). Unfortunately that&#8217;s not what happened. For some weird reason seems that the SharePoint API was trying to impersonate the current user thus throwing an exception and showing an Access Denied error which said  <em>Access Denied: Only an administrator may retrieve a count of all users. </em></p>
<p><em>So after sleepless nights (just kidding it was just some banging my head on the wall), I finally remembered to take a look at an old code snippet that I had when facing the same issue in the past, and I&#8217;ve decided to write this post (blog posts are a great way to use as a diary). </em></p>
<h3>The Workaround</h3>
<p><em>Basically my workaround is to set the current HttpContext to null inside the code, but keeping the existing context in a temp variable so I can revert it back once I run the snippet. You have to revert it back to the original context otherwise you are going to get a lot of errors. The code looks like this:</em><em> </em></p>
<p><pre class="brush: csharp; highlight: [2,10,15];">
SPSite siteColl = SPContext.Current.Site;
HttpContext tempCtx = HttpContext.Current;

try
{
SPSecurity.RunWithElevatedPrivileges(delegate() {
using (SPSite ElevatedsiteColl = new SPSite(siteColl.ID))
{
SPServiceContext serviceContext = SPServiceContext.GetContext(ElevatedsiteColl);
HttpContext.Current = null;
UserProfileManager profileManager = new UserProfileManager(serviceContext);
ProfileCount = profileManager.Count;} });
}
catch (Exception ex){ LogException(ex);}
finally{ HttpContext.Current = tempCtx;}

</pre></p>
<p><em>Using the code above I could retrieve the count even using a regular user (no admin access) .</em></p>
<p><em> I hope this saves some time on your side and avoid some head banging on the wall</em></p>
<p><em>Have a nice one !</em></p>
<p><em>Andy Nogueira.</em></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/socialsp.wordpress.com/129/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/socialsp.wordpress.com/129/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/socialsp.wordpress.com/129/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/socialsp.wordpress.com/129/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/socialsp.wordpress.com/129/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/socialsp.wordpress.com/129/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/socialsp.wordpress.com/129/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/socialsp.wordpress.com/129/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/socialsp.wordpress.com/129/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/socialsp.wordpress.com/129/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/socialsp.wordpress.com/129/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/socialsp.wordpress.com/129/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/socialsp.wordpress.com/129/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/socialsp.wordpress.com/129/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=socialsp.com&amp;blog=10599735&amp;post=129&amp;subd=socialsp&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://socialsp.com/2010/11/25/access-denied-messages-when-retrieving-sharepoint-user-profiles-count-even-running-in-elevated-code/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/d923a9f76162684e4554196c103d1cf1?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Andy Nogueira</media:title>
		</media:content>
	</item>
		<item>
		<title>SPWeb.CurrentUser returns SHAREPOINT\System not the real user name.</title>
		<link>http://socialsp.com/2010/08/26/spweb-currentuser-returns-sharepointsystem-not-the-real-user-name/</link>
		<comments>http://socialsp.com/2010/08/26/spweb-currentuser-returns-sharepointsystem-not-the-real-user-name/#comments</comments>
		<pubDate>Thu, 26 Aug 2010 18:39:12 +0000</pubDate>
		<dc:creator>anogueira</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://socialsp.com/?p=120</guid>
		<description><![CDATA[If you try to get the current user login name or name in SharePoint and if it shows SHAREPOINT\System account, that&#8217;s because the current logged user is an admin account and is probably the one used in the application pool &#8230; <a href="http://socialsp.com/2010/08/26/spweb-currentuser-returns-sharepointsystem-not-the-real-user-name/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=socialsp.com&amp;blog=10599735&amp;post=120&amp;subd=socialsp&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>If you try to get the current user login name or name in SharePoint and if it shows SHAREPOINT\System account, that&#8217;s because the current logged user is an admin account and is probably the one used in the application pool of the site. Also, you are probably getting the current user from an  elevated SPWeb inside a RunWithElevatedPrivileges code. You can use the snippet  below to get the real user:</p>
<p><pre class="brush: csharp;">

SPWeb site = SPContext.Current.Web;
SPSecurity.RunWithElevatedPrivileges(delegate()
{
  using (SPSite ElevatedsiteColl = new SPSite(siteColl.ID))
  {
    using (SPWeb ElevatedSite = ElevatedsiteColl.OpenWeb(site.ID))
    {
      //Don't use the ElevatedSite.CurrentUser
      string currUser = site.CurrentUser;
    }
  }
});

</pre></p>
<p>This will show the real login name instead of SHAREPOINT\System</p>
<p>Bear in mind that the code above is just a snippet and to show you the idea. Please make sure you use the <a href="http://msdn.microsoft.com/en-us/library/bb687949%28office.12%29.aspx" target="_blank">SharePoint best practices coding for disposing objects</a> when using the snippet above.</p>
<p>Hope that helps !</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/socialsp.wordpress.com/120/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/socialsp.wordpress.com/120/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/socialsp.wordpress.com/120/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/socialsp.wordpress.com/120/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/socialsp.wordpress.com/120/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/socialsp.wordpress.com/120/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/socialsp.wordpress.com/120/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/socialsp.wordpress.com/120/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/socialsp.wordpress.com/120/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/socialsp.wordpress.com/120/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/socialsp.wordpress.com/120/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/socialsp.wordpress.com/120/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/socialsp.wordpress.com/120/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/socialsp.wordpress.com/120/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=socialsp.com&amp;blog=10599735&amp;post=120&amp;subd=socialsp&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://socialsp.com/2010/08/26/spweb-currentuser-returns-sharepointsystem-not-the-real-user-name/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/d923a9f76162684e4554196c103d1cf1?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Andy Nogueira</media:title>
		</media:content>
	</item>
		<item>
		<title>Changing namespace in Visual Studio 2010 might break a SharePoint 2010 webpart project</title>
		<link>http://socialsp.com/2010/08/24/changing-namespace-in-visual-studio-2010-might-break-a-sharepoint-2010-webpart-project/</link>
		<comments>http://socialsp.com/2010/08/24/changing-namespace-in-visual-studio-2010-might-break-a-sharepoint-2010-webpart-project/#comments</comments>
		<pubDate>Tue, 24 Aug 2010 20:14:03 +0000</pubDate>
		<dc:creator>anogueira</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[SharePoint]]></category>

		<guid isPermaLink="false">http://socialsp.com/?p=96</guid>
		<description><![CDATA[Just want to create a post about this since it&#8217;s the second time this happened to me and I wished this second time I had created this post when I experienced this error for the first time so I could &#8230; <a href="http://socialsp.com/2010/08/24/changing-namespace-in-visual-studio-2010-might-break-a-sharepoint-2010-webpart-project/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=socialsp.com&amp;blog=10599735&amp;post=96&amp;subd=socialsp&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Just want to create a post about this since it&#8217;s the second time this happened to me and I wished this second time I had created this post when I experienced this error for the first time so I could check my own blog and figure out what was happening. Blogs can be used as journals too for our own help <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>I was creating a SharePoint 2010 project in Visual Studio 2010. I&#8217;ve selected the Empty Project and then Add New Item and selected the Webpart item (not the Visual Webpart). After doing some coding, for some reason I&#8217;ve decided to change the original namespace that Visual Studio had created for me on the webpart class (.cs file). Then I did some more coding and time to test it. I right click on the project name and select Deploy (I love this new feature in VS2010). Everything goes smooth, package is deployed and everything seems fine. So I go to my SharePoint site, Edit the page, Insert a Webpart, select my new custom webpart and when I hit the Add button, for my surprise I got the error below.</p>
<p><a href="http://socialsp.files.wordpress.com/2010/08/spwebparterr.jpg"><img class="alignleft size-full wp-image-108" title="spwebparterr" src="http://socialsp.files.wordpress.com/2010/08/spwebparterr.jpg?w=500" alt=""   /></a></p>
<p>And this is the second time around that this happened to me. The first time was a long time ago so I couldn&#8217;t remember why. Then it&#8217;s time to do some troubleshooting. I&#8217;ve verified that the .DLL file was in the GAC, I&#8217;ve checked the web.config file to make sure a &lt;SafeControl&gt; entry was created. Everything looks good. Then I check the webpart definintion file in the WebParts gallery and closely looking at the XML I&#8217;ve noticed that the namespace was not matching with my webpart class. The original namespace was still showing. So I went back to my Visual Studio project and I&#8217;ve opened the .webpart file (see below) that was created for me.</p>
<p style="text-align:center;"><a href="http://socialsp.files.wordpress.com/2010/08/webpart.jpg"><img class="size-full wp-image-103 aligncenter" title="webpart file" src="http://socialsp.files.wordpress.com/2010/08/webpart.jpg?w=500" alt=""   /></a></p>
<p>And for my surprise the original namespace was still showing up there. So if you change your namespace after you create a project in VS2010 make sure that in the .webpart file (see below) under the &lt;Metadata&gt; &lt;type&gt; elements, the name attribute has the correct namespace.</p>
<p><pre class="brush: xml;">

&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;webParts&gt;
&lt;webPart xmlns=&quot;http://schemas.microsoft.com/WebPart/v3&quot;&gt;
&lt;metaData&gt;
&lt;type name=&quot;SP2010.WebParts.MembesListingWebPart.MembersListingWebPart, $SharePoint.Project.AssemblyFullName$&quot; /&gt;
&lt;importErrorMessage&gt;$Resources:core,ImportErrorMessage;&lt;/importErrorMessage&gt;
&lt;/metaData&gt;
&lt;data&gt;
&lt;properties&gt;
&lt;property name=&quot;Title&quot; type=&quot;string&quot;&gt;Members Listing WebPart&lt;/property&gt;
&lt;property name=&quot;Description&quot; type=&quot;string&quot;&gt;This WebPart lists the members of a site&lt;/property&gt;
&lt;/properties&gt;
&lt;/data&gt;
&lt;/webPart&gt;
&lt;/webParts&gt;

</pre></p>
<p>Another change you have to do and this one is a tricky one is on the Visual Studio 2010 SharePointProjectItem.spdata file. This is a file I believe Visual Studio uses internally to package and deploy the solution. But the catch is that it doesn&#8217;t show by default, so you have to click on the &#8220;Show All Files&#8221; button in the Solution Explorer and this file will show inside your WebPart folder (see below). Edit the file and change the Namespace attributes according to your new namespace.</p>
<p style="text-align:center;"><a href="http://socialsp.files.wordpress.com/2010/08/showall.jpg"><img class="size-full wp-image-117 aligncenter" title="showall" src="http://socialsp.files.wordpress.com/2010/08/showall.jpg?w=500" alt=""   /></a></p>
<p>Also, don&#8217;t forget in that if you change the namespace, in your project properties, make sure it&#8217;s reflected in the Default Namespace field in the Application tab of your Project properties (right-click your project name and select properties).</p>
<p>Hope this will help some people save some troubleshooting time !</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/socialsp.wordpress.com/96/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/socialsp.wordpress.com/96/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/socialsp.wordpress.com/96/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/socialsp.wordpress.com/96/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/socialsp.wordpress.com/96/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/socialsp.wordpress.com/96/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/socialsp.wordpress.com/96/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/socialsp.wordpress.com/96/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/socialsp.wordpress.com/96/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/socialsp.wordpress.com/96/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/socialsp.wordpress.com/96/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/socialsp.wordpress.com/96/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/socialsp.wordpress.com/96/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/socialsp.wordpress.com/96/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=socialsp.com&amp;blog=10599735&amp;post=96&amp;subd=socialsp&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://socialsp.com/2010/08/24/changing-namespace-in-visual-studio-2010-might-break-a-sharepoint-2010-webpart-project/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/d923a9f76162684e4554196c103d1cf1?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Andy Nogueira</media:title>
		</media:content>

		<media:content url="http://socialsp.files.wordpress.com/2010/08/spwebparterr.jpg" medium="image">
			<media:title type="html">spwebparterr</media:title>
		</media:content>

		<media:content url="http://socialsp.files.wordpress.com/2010/08/webpart.jpg" medium="image">
			<media:title type="html">webpart file</media:title>
		</media:content>

		<media:content url="http://socialsp.files.wordpress.com/2010/08/showall.jpg" medium="image">
			<media:title type="html">showall</media:title>
		</media:content>
	</item>
		<item>
		<title>Manage Access Requests not showing on a SharePoint 2010 site</title>
		<link>http://socialsp.com/2010/06/01/manage-access-requests-not-showing-on-a-sharepoint-2010-site/</link>
		<comments>http://socialsp.com/2010/06/01/manage-access-requests-not-showing-on-a-sharepoint-2010-site/#comments</comments>
		<pubDate>Tue, 01 Jun 2010 16:21:03 +0000</pubDate>
		<dc:creator>anogueira</dc:creator>
				<category><![CDATA[Configuration]]></category>
		<category><![CDATA[SharePoint]]></category>

		<guid isPermaLink="false">http://socialsp.com/?p=85</guid>
		<description><![CDATA[The other day I was just trying to get to the Manage Access request option on SharePoint 2010 and for my surprise I couldn&#8217;t find the link to get to the page. So in order to figure it out, I &#8230; <a href="http://socialsp.com/2010/06/01/manage-access-requests-not-showing-on-a-sharepoint-2010-site/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=socialsp.com&amp;blog=10599735&amp;post=85&amp;subd=socialsp&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>The other day I was just trying to get to the Manage Access request option on SharePoint 2010 and for my surprise I couldn&#8217;t find the link to get to the page.</p>
<p>So in order to figure it out, I went to a MOSS 2007 site, and I knew I could get to it going to <strong>Site settings -&gt; Advanced permissions -&gt; Settings -&gt; Access requests</strong>, this showed me that this page name and location was /_layouts/setrqacc.aspx. I thought that Microsoft probably haven&#8217;t changed this on SharePoint 2010. So I went back to my SP2010 server and appended this location to my site&#8217;s URL. For my surprise I got an error message that gave me an insight on what was going on. The message said something about emails not being configured.</p>
<p>So I went to the SharePoint 2010 <strong>Central Admin</strong> site, and under <strong>System Settings</strong> -&gt; <strong>Configure outgoing e-mail settings</strong>, once I configured the smtp server and outgoing email.</p>
<p><a href="http://socialsp.files.wordpress.com/2010/06/configemail.png"><img class="alignleft size-full wp-image-94" title="Configure Email settings" src="http://socialsp.files.wordpress.com/2010/06/configemail.png?w=500&#038;h=191" alt="" width="500" height="191" /></a></p>
<p>Then I tried to access the page again and it worked. I&#8217;ve also realized that one option in SharePoint 2010 that I was not seeing before started to show up, and that was a link on the Ribbon going to Site Settings -&gt; Site Permissions. The link that said Manage Access Requests (see below) started to show up.</p>
<p><a href="http://socialsp.files.wordpress.com/2010/06/accessreq.png"><img class="alignleft size-full wp-image-86" title="Access Request" src="http://socialsp.files.wordpress.com/2010/06/accessreq.png?w=500&#038;h=85" alt="" width="500" height="85" /></a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/socialsp.wordpress.com/85/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/socialsp.wordpress.com/85/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/socialsp.wordpress.com/85/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/socialsp.wordpress.com/85/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/socialsp.wordpress.com/85/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/socialsp.wordpress.com/85/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/socialsp.wordpress.com/85/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/socialsp.wordpress.com/85/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/socialsp.wordpress.com/85/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/socialsp.wordpress.com/85/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/socialsp.wordpress.com/85/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/socialsp.wordpress.com/85/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/socialsp.wordpress.com/85/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/socialsp.wordpress.com/85/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=socialsp.com&amp;blog=10599735&amp;post=85&amp;subd=socialsp&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://socialsp.com/2010/06/01/manage-access-requests-not-showing-on-a-sharepoint-2010-site/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/d923a9f76162684e4554196c103d1cf1?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Andy Nogueira</media:title>
		</media:content>

		<media:content url="http://socialsp.files.wordpress.com/2010/06/configemail.png" medium="image">
			<media:title type="html">Configure Email settings</media:title>
		</media:content>

		<media:content url="http://socialsp.files.wordpress.com/2010/06/accessreq.png" medium="image">
			<media:title type="html">Access Request</media:title>
		</media:content>
	</item>
		<item>
		<title>SilverPart 2.1 release, a SharePoint webpart to expose Silverlight applications</title>
		<link>http://socialsp.com/2010/05/15/silverpart-2-1-release-a-sharepoint-webpart-to-expose-silverlight-applications/</link>
		<comments>http://socialsp.com/2010/05/15/silverpart-2-1-release-a-sharepoint-webpart-to-expose-silverlight-applications/#comments</comments>
		<pubDate>Sat, 15 May 2010 03:30:48 +0000</pubDate>
		<dc:creator>anogueira</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[MOSS]]></category>
		<category><![CDATA[SharePoint]]></category>
		<category><![CDATA[Silverlight]]></category>

		<guid isPermaLink="false">https://socialsp.wordpress.com/2010/05/15/silverpart-2-1-release-a-sharepoint-webpart-to-expose-silverlight-applications/</guid>
		<description><![CDATA[I&#8217;ve just released a new update of the SilverPart on CodePlex. For those who don&#8217;t know this is an open source webpart I&#8217;ve created some time ago and it allows you to run Silverlight applications in WSS 3 and MOSS &#8230; <a href="http://socialsp.com/2010/05/15/silverpart-2-1-release-a-sharepoint-webpart-to-expose-silverlight-applications/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=socialsp.com&amp;blog=10599735&amp;post=83&amp;subd=socialsp&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve just released a new update of the SilverPart on CodePlex. For those who don&#8217;t know this is an open source webpart I&#8217;ve created some time ago and it allows you to run Silverlight applications in WSS 3 and MOSS 2007.</p>
<p>SharePoint 2010 comes with a webpart like this OOTB, but in the old SharePoint (2007) this was not available. The nice thing about it was that I&#8217;ve created it in a way that you didn&#8217;t have to install additional software such as the ASP.NET Silverlight control.</p>
<p>This interim release 2.1 fixes some reported issues with using it with Firefox and anonymous access.</p>
<p>You can download it from http://silverpart.codeplex.com</p>
<p>Cheers</p>
<p>Andy Nogueira</p>
<p>P.S &#8211; What I really liked about CodePlex is that now you can insert Ads on their page and I&#8217;ve opted to donate the Ad revenue, so I&#8217;m not only giving back to the community but I&#8217;m also helping a good cause. </p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/socialsp.wordpress.com/83/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/socialsp.wordpress.com/83/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/socialsp.wordpress.com/83/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/socialsp.wordpress.com/83/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/socialsp.wordpress.com/83/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/socialsp.wordpress.com/83/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/socialsp.wordpress.com/83/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/socialsp.wordpress.com/83/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/socialsp.wordpress.com/83/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/socialsp.wordpress.com/83/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/socialsp.wordpress.com/83/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/socialsp.wordpress.com/83/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/socialsp.wordpress.com/83/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/socialsp.wordpress.com/83/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=socialsp.com&amp;blog=10599735&amp;post=83&amp;subd=socialsp&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://socialsp.com/2010/05/15/silverpart-2-1-release-a-sharepoint-webpart-to-expose-silverlight-applications/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/d923a9f76162684e4554196c103d1cf1?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Andy Nogueira</media:title>
		</media:content>
	</item>
		<item>
		<title>Twitter and Facebook compared to Sharepoint social model</title>
		<link>http://socialsp.com/2009/12/18/twitter-and-facebook-compared-to-sharepoint-social-model/</link>
		<comments>http://socialsp.com/2009/12/18/twitter-and-facebook-compared-to-sharepoint-social-model/#comments</comments>
		<pubDate>Fri, 18 Dec 2009 04:19:12 +0000</pubDate>
		<dc:creator>anogueira</dc:creator>
				<category><![CDATA[SharePoint]]></category>
		<category><![CDATA[Social Computing]]></category>
		<category><![CDATA[facebook]]></category>
		<category><![CDATA[twitter]]></category>

		<guid isPermaLink="false">http://socialsp.wordpress.com/2009/12/18/twitter-and-facebook-compared-to-sharepoint-social-model/</guid>
		<description><![CDATA[Just got a message that a post I&#8217;ve created on my company&#8217;s blog some time ago has been active recently in Twitter. It compares Sharepoint network model with Toronto and Facebook. Here&#8217;s the link to the post http://www.nonlinearcreations.com/blog/index.php/2009/09/01/sharepoint-social-model-more-similar-to-twitter-than-other-social-networking-sites/ Thanks Andy &#8230; <a href="http://socialsp.com/2009/12/18/twitter-and-facebook-compared-to-sharepoint-social-model/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=socialsp.com&amp;blog=10599735&amp;post=82&amp;subd=socialsp&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Just got a message that a post I&#8217;ve created on my company&#8217;s blog some time ago has been active recently in Twitter. It compares Sharepoint network model with Toronto and Facebook. Here&#8217;s the link to the post</p>
<p>http://www.nonlinearcreations.com/blog/index.php/2009/09/01/sharepoint-social-model-more-similar-to-twitter-than-other-social-networking-sites/</p>
<p>Thanks</p>
<p>Andy Nogueira</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/socialsp.wordpress.com/82/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/socialsp.wordpress.com/82/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/socialsp.wordpress.com/82/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/socialsp.wordpress.com/82/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/socialsp.wordpress.com/82/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/socialsp.wordpress.com/82/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/socialsp.wordpress.com/82/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/socialsp.wordpress.com/82/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/socialsp.wordpress.com/82/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/socialsp.wordpress.com/82/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/socialsp.wordpress.com/82/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/socialsp.wordpress.com/82/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/socialsp.wordpress.com/82/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/socialsp.wordpress.com/82/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=socialsp.com&amp;blog=10599735&amp;post=82&amp;subd=socialsp&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://socialsp.com/2009/12/18/twitter-and-facebook-compared-to-sharepoint-social-model/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/d923a9f76162684e4554196c103d1cf1?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Andy Nogueira</media:title>
		</media:content>
	</item>
		<item>
		<title>Having fun with the new LINQ to SharePoint on SharePoint 2010 (SP2010)</title>
		<link>http://socialsp.com/2009/12/11/having-fun-with-the-new-linq-to-sharepoint-on-sharepoint-2010-sp2010/</link>
		<comments>http://socialsp.com/2009/12/11/having-fun-with-the-new-linq-to-sharepoint-on-sharepoint-2010-sp2010/#comments</comments>
		<pubDate>Fri, 11 Dec 2009 17:30:32 +0000</pubDate>
		<dc:creator>anogueira</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[SharePoint]]></category>
		<category><![CDATA[LINQ to SharePoint]]></category>
		<category><![CDATA[sharepoint 2010]]></category>

		<guid isPermaLink="false">http://socialsp.com/?p=43</guid>
		<description><![CDATA[Introduction This will be my first post on the new LINQ to SharePoint feature available in SharePoint 2010. I&#8217;ve decided to give it a try. I thought that it would be so much easier for me to retrieve SharePoint information &#8230; <a href="http://socialsp.com/2009/12/11/having-fun-with-the-new-linq-to-sharepoint-on-sharepoint-2010-sp2010/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=socialsp.com&amp;blog=10599735&amp;post=43&amp;subd=socialsp&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h2><span style="font-weight:normal;">Introduction</span></h2>
<p>This will be my first post on the new LINQ to SharePoint feature available in SharePoint 2010. I&#8217;ve decided to give it a try. I thought that it would be so much easier for me to retrieve SharePoint information using LINQ than creating CAML code since I&#8217;m very familiar with LINQ and used it a lot of times, especially LINQ to SQL and LINQ to Objects. But this previous knowledge on LINQ also played some tricks on me since that usually we tend to take a lot of things for granted when dealing with new technologies. So, here&#8217;s how I&#8217;ve started.</p>
<p>First I&#8217;ve watched one of the <a title="SharePoint 2010 Developer videos" href="http://channel9.msdn.com/learn/courses/SharePoint2010Developer/" target="_blank">SharePoint 2010 Developer videos on Channel 9</a> related to LINQ to SharePoint. This was a good overview about the technology with a good demo. Then I&#8217;ve followed the walk-through on the SharePoint 2010 book that was distributed at the SharePoint Conference 2009. The walk-through is the one on page 162 called <em>&#8220;Using LINQ to SharePoint from within a Visual Web Part&#8221;</em>. That also gave me a better insight and a nice idea on how to use it in a Visual WebPart.</p>
<p>So, the first thing you need to do to use LINQ to SharePoint is to generate a mapping layer (same idea as LINQ to SQL) where you can have your SharePoint list definitions generated as C# (or VB) .NET classes. That will give you strongly-typed classes of your SharePoint schema. Again, just keep in mind that if you do change your SharePoint list definition you will probably need to re-generate this mapping layer. In order to generate this, you have to use a tool called <strong>SPMetal</strong></p>
<h2><strong><span style="font-weight:normal;">Step 1 &#8211; Using SPMetal to generate a mapping layer</span></strong></h2>
<p>The tool SPMetal is installed as part of the SharePoint 2010 installation and it&#8217;s located by default at &#8220;<em>C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\BIN&#8221;. </em>If you open a command prompt, go to that folder and type spmetal, it will show you a description of its valid parameters. There&#8217;s also a <a title="SPMetal" href="http://msdn.microsoft.com/en-us/library/ee538255(office.14).aspx" target="_blank">good article on MSDN about SPMetal</a>.</p>
<p>Basically the main parameters are the site URL, the namespace, the filename and the type of file (.cs or .vb). Here&#8217;s an example:</p>
<pre>c:\&gt;SPMetal /web:http://localserver/team /namespace:MyCompany.Data /code:TeamSite.cs</pre>
<p>This command will basically generate a CSharp file where I can import into your Visual Studio 2010 project.</p>
<h2><span style="font-weight:normal;">Step 2 &#8211; Using a parameters file to override the SPMetal default rules</span></h2>
<p>There is also an additional option in SPMetal called <em>parameters</em> where you can specify a XML file that allows you to override the default rules to generate the mapping layer. So let&#8217;s say you want to specify which lists you want in your mapping file. You can use for example a file called myParameters.xml (it can be any filename as long as you specify the name right on the command-line).</p>
<pre>c:\&gt;SPMetal /web:http://localserver/team /namespace:MyCompany.Data /code:TeamSite.cs /parameters:myParameters.xml</pre>
<p>The first time I&#8217;ve tried to use a parameters file, I&#8217;ve got a bunch of errors trying to generate the file. Some of these errors were related to a copying and paste problem from the MSDN article to my file. So make sure you use a valid XML editor instead of Notepad because the double quotes can play a trick on you. By using a XML editor you can guarantee that there are no malformed XML in your parameters file.</p>
<p>Also, make sure you understand the right schema for the parameters file. In the beginning I&#8217;ve also had problems because I was putting the XML elements in my file in an invalid order. Also, make sure that you understand what elements are parents and children of each other. It took me some trial and errors until I could figure it out, but it&#8217;d have saved me sometime if I had found earlier the really nice MSDN article describing the whole parameters file schema (see below)</p>
<p>These  two articles are a must read to be able to come up with a nice parameters  XML file</p>
<p><a title="Overriding SPMetal Defaults with a Parameters XML File" href="http://msdn.microsoft.com/en-us/library/ee535056(office.14).aspx" target="_blank">Overriding SPMetal Defaults with a Parameters XML File</a></p>
<p><a title="SPMetal Parameters XML Schema" href="http://msdn.microsoft.com/en-us/library/ee535058(office.14).aspx" target="_blank">SPMetal Parameters XML Schema</a></p>
<p>So let&#8217;s say you have a list in SharePoint in your site called &#8220;Customer&#8221;. Let&#8217;s assume that you are not using any custom Content Type on that list (assuming in this case it&#8217;s a pretty vanilla custom list). If you want to generate a mapping layer that will have only the Customer list and you want spmetal to generate fields for some out-of-the-box SharePoint fields such as the Author and Created you can (see below). There&#8217;s also a parameter called &lt;ExcludeOtherLists&gt; that tells SPMetal to generate classes for only the lists that you&#8217;ve specified. That can be pretty handy in case you don&#8217;t want to have a huge mapping layer file. So here&#8217;s an example:</p>
<p><strong><span style="text-decoration:underline;">myParameters.xml</span></strong></p>
<p><pre class="brush: xml;">
  &lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
  &lt;Web AccessModifier=&quot;Internal&quot; xmlns=&quot;http://schemas.microsoft.com/SharePoint/2009/spmetal&quot;&gt;
    &lt;List Name=&quot;Customer&quot;&gt;
      &lt;ContentType Name=&quot;Item&quot; Class=&quot;Customer&quot; &gt;
        &lt;Column Name=&quot;Author&quot; Member=&quot;Author&quot; /&gt;
        &lt;Column Name=&quot;Created&quot; Member=&quot;Created&quot; /&gt;
        &lt;Column Name=&quot;Description&quot; Member=&quot;Description&quot; /&gt;
      &lt;/ContentType&gt;
    &lt;/List&gt;
    &lt;ExcludeOtherLists /&gt;
  &lt;/Web&gt;
</pre></p>
<p>Once the file is generated you can go to your project in Visual Studio 2010 (I&#8217;m assuming that you&#8217;ve already created one of the SharePoint 2010 project templates such as the Visual WebPart one) and add the file to your project by righ-clicking on your project name and selecting <strong>Add | Existing Item.</strong> Browse to the folder where you generated the file, select it and click <strong>Add</strong>.</p>
<p><a href="http://socialsp.files.wordpress.com/2009/12/additemvs.jpg"><img class="alignleft size-full wp-image-71" title="additemVS" src="http://socialsp.files.wordpress.com/2009/12/additemvs.jpg?w=500&#038;h=362" alt="Add Item in Visual Studio" width="500" height="362" /></a></p>
<h2><span style="font-weight:normal;">Step 3 &#8211; Adding LINQ to SharePoint references</span></h2>
<p>Rigth-click on your project again and select <strong>Add Reference</strong>. The Add Reference window will show up.Just select the <strong>Microsoft.SharePoint.Linq.dll</strong></p>
<p><a href="http://socialsp.files.wordpress.com/2009/12/vs2010linqtosp1.jpg"><img class="alignleft size-full wp-image-65" title="VS2010LinqToSP" src="http://socialsp.files.wordpress.com/2009/12/vs2010linqtosp1.jpg?w=500&#038;h=193" alt="" width="500" height="193" /></a></p>
<p>Once the Microsoft.SharePoint.Linq.dll is referenced then you need to add the following using statements on your code (if you didn&#8217;t generate the mapping layer with the same namespace as the class namespace where you will be using it, then you have to add this namespace too).</p>
<p><pre class="brush: csharp;">

using System.Linq;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Linq;
using MyCompany.Data;  /* My mapping layer namespace */

</pre></p>
<p>Now that you have your mapping layer and the required references in place it&#8217;s now time to have some fun. Let&#8217;s get our hand dirty with some Linq code.</p>
<h2><span style="font-weight:normal;">Step 4 &#8211; Retrieving SharePoint information using Linq</span></h2>
<p><span style="font-weight:normal;">If you open your mapping file (in my case TeamSite.cs) you will see that SPMetal created a DataContext class for you and it should look like this</span></p>
<p><span style="font-weight:normal;"> </span></p>
<p><pre class="brush: csharp;">
internal partial class TeamSiteDataContext : Microsoft.SharePoint.Linq.DataContext {}
</pre></p>
<p><span style="font-weight:normal;">You can also see that for the list that you&#8217;ve specified (in my case Customers) there was also a member created for that in this class, something like</span></p>
<p><pre class="brush: csharp;">
[Microsoft.SharePoint.Linq.ListAttribute(Name=&quot;Customers&quot;)]
public Microsoft.SharePoint.Linq.EntityList&lt;Customer&gt; Customers{}
</pre></p>
<p>Now the fun part. In order to retrieve Customers from SharePoint I need to instantiate a DataContext class, load the list and iterate the items. You can use something like this code below in your WebPart code-behind or Visual WebPart User Control (ascx) code-behind.</p>
<p><pre class="brush: csharp;">
try{
 using(TeamSiteDataContext ctx = new TeamSiteDataContext(SPContext.Current.Web.Url))
 {
  ctx.ObjectTrackingEnabled = false; //this is good for performance if you are only retrieving information
  EntityList&lt;Customer&gt; Customers = ctx.GetList&lt;Customer&gt;(&quot;Customers&quot;);
  var query = from c in Customers.ToList()
              select c;
  foreach(var cust in query)
  {
    //Do something here. The objects are strongly typed so I could do something like cust.Name for example
  }
 }
</pre></p>
<p>This <a title="Using Linq to SharePoint" href="http://msdn.microsoft.com/en-us/library/ee538250(office.14).aspx" target="_blank">MSDN link</a> has some additional details on how to use this and have a few more examples.</p>
<h2><span style="font-weight:normal;">Gotchas and Limitations</span></h2>
<p><span style="font-weight:normal;">While &#8220;playing&#8221; with LINQ to SharePoint I&#8217;ve tried to do &#8220;wild&#8221; things that were pretty common in LINQ to SQL such as joins. So when I mentioned in the beginning of this post that you should never take things for granted, believe me this is one of this cases. There are some limitations in what you can do with LINQ to SharePoint and some LINQ constructs are not even possible. There are some that are possible but are called &#8220;inefficient&#8221;. Make sure you read this article first before trying to do &#8220;wild&#8221; things: <a title="Efficient, Inefficient, and Unsupported LINQ Queries" href="http://msdn.microsoft.com/en-us/library/ee536585(office.14).aspx" target="_blank">Efficient, Inefficient, and Unsupported LINQ Queries</a></span></p>
<p>I&#8217;ve tried to do some joins in my LINQ based on two SharePoint lists linked by a lookup field but I&#8217;ve got a strange error message saying something about that Inneficient Queries were not allowed and I should change a property on my DataContext. Reading the article above (on Step 4) it says that you should set a property called <em>AllowInefficientQueries()</em> to true but I couldn&#8217;t find this property in my DataContext class. I&#8217;ve searched the web and found some people saying that as of Beta2 this is not there anymore, so I&#8217;m assuming this was in a previous beta but the documentation was not updated accordingly (but this needs to be confirmed).</p>
<h2><span style="font-weight:normal;">Conclusion</span></h2>
<p>LINQ to SharePoint is very promising and it can speed up things a lot if you need to retrieve and update information in SharePoint. It&#8217;s a great alternative to creating custom CAML code and it might leverage some of your existing knowledge in LINQ especially if you already done a bunch of them. If you haven&#8217;t then a good LINQ book (but doens&#8217;t cover LINQ to SharePoint) is <a title="Pro Linq book" href="http://www.amazon.com/Pro-LINQ-Language-Integrated-Windows-Net/dp/1590597893/ref=sr_1_1?ie=UTF8&amp;s=books&amp;qid=1260567279&amp;sr=8-1" target="_blank">Pro Linq from Apress</a>.</p>
<p>Hope that helps and have fun coding with LINQ to SharePoint in SharePoint 2010 !</p>
<p>Cheers,</p>
<p>Andy Nogueira.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/socialsp.wordpress.com/43/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/socialsp.wordpress.com/43/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/socialsp.wordpress.com/43/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/socialsp.wordpress.com/43/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/socialsp.wordpress.com/43/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/socialsp.wordpress.com/43/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/socialsp.wordpress.com/43/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/socialsp.wordpress.com/43/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/socialsp.wordpress.com/43/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/socialsp.wordpress.com/43/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/socialsp.wordpress.com/43/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/socialsp.wordpress.com/43/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/socialsp.wordpress.com/43/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/socialsp.wordpress.com/43/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=socialsp.com&amp;blog=10599735&amp;post=43&amp;subd=socialsp&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://socialsp.com/2009/12/11/having-fun-with-the-new-linq-to-sharepoint-on-sharepoint-2010-sp2010/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/d923a9f76162684e4554196c103d1cf1?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Andy Nogueira</media:title>
		</media:content>

		<media:content url="http://socialsp.files.wordpress.com/2009/12/additemvs.jpg" medium="image">
			<media:title type="html">additemVS</media:title>
		</media:content>

		<media:content url="http://socialsp.files.wordpress.com/2009/12/vs2010linqtosp1.jpg" medium="image">
			<media:title type="html">VS2010LinqToSP</media:title>
		</media:content>
	</item>
		<item>
		<title>Links not enabled on SharePoint 2010 Central Administration Site</title>
		<link>http://socialsp.com/2009/12/03/links-not-enabled-on-sharepoint-2010-central-administration-site/</link>
		<comments>http://socialsp.com/2009/12/03/links-not-enabled-on-sharepoint-2010-central-administration-site/#comments</comments>
		<pubDate>Thu, 03 Dec 2009 23:02:25 +0000</pubDate>
		<dc:creator>anogueira</dc:creator>
				<category><![CDATA[Configuration]]></category>
		<category><![CDATA[SharePoint]]></category>
		<category><![CDATA[sharepoint 2010]]></category>

		<guid isPermaLink="false">http://socialsp.com/?p=37</guid>
		<description><![CDATA[Here&#8217;s a quick tip that may save some people a lot of time. I have a standalone SharePoint 2010 environment installed on my desktop for development purposes (Vista 64-bit). I was trying to create a new web application to host &#8230; <a href="http://socialsp.com/2009/12/03/links-not-enabled-on-sharepoint-2010-central-administration-site/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=socialsp.com&amp;blog=10599735&amp;post=37&amp;subd=socialsp&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s a quick tip that may save some people a lot of time. I have a standalone SharePoint 2010 environment installed on my desktop for development purposes (Vista 64-bit). I was trying to create a new web application to host my site but for my surprise when I went to <strong><em>Central Administration -&gt; Application Management -&gt; Manage Web Applications</em></strong>, the ribbon wouldn&#8217;t show some of the buttons enabled (see image below). When I clicked on one of the web applications I saw only a few buttons on the ribbon enabled. That was strange because I was pretty sure I&#8217;m a farm administrator.</p>
<p><a href="http://socialsp.files.wordpress.com/2009/12/disabledcentraladmin1.jpg"><img class="alignleft size-full wp-image-39" title="disabledCentralAdmin" src="http://socialsp.files.wordpress.com/2009/12/disabledcentraladmin1.jpg?w=500&#038;h=71" alt="" width="500" height="71" /></a></p>
<p>While doing some research on what might be causing this problem I&#8217;ve realized that I had to access the Central Admin site in a different way. So this is what I did.</p>
<ul>
<li>Please make sure to add the Central Administration site to the Intranet zone</li>
<li>Run Internet Explorer as Administrator (right-click the icon and select Run as administrator)</li>
<li>Not sure if this makes a difference, but I&#8217;ve also used the IE 64-bit version</li>
</ul>
<p>Once I&#8217;ve did that I&#8217;ve tried to access the site again, using the same login credentials and voilá. For my surprise some of the buttons that were disabled before this time were enabled (see image below). And I was able to click on New button to create a new web application.</p>
<p><a href="http://socialsp.files.wordpress.com/2009/12/enabledcentraladmin.jpg"><img class="alignleft size-full wp-image-36" title="enabledCentralAdmin" src="http://socialsp.files.wordpress.com/2009/12/enabledcentraladmin.jpg?w=500&#038;h=72" alt="" width="500" height="72" /></a></p>
<p>Hope that this can save some people some time.</p>
<p>cheers,</p>
<p>Andy Nogueira</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/socialsp.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/socialsp.wordpress.com/37/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/socialsp.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/socialsp.wordpress.com/37/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/socialsp.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/socialsp.wordpress.com/37/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/socialsp.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/socialsp.wordpress.com/37/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/socialsp.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/socialsp.wordpress.com/37/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/socialsp.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/socialsp.wordpress.com/37/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/socialsp.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/socialsp.wordpress.com/37/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=socialsp.com&amp;blog=10599735&amp;post=37&amp;subd=socialsp&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://socialsp.com/2009/12/03/links-not-enabled-on-sharepoint-2010-central-administration-site/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/d923a9f76162684e4554196c103d1cf1?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Andy Nogueira</media:title>
		</media:content>

		<media:content url="http://socialsp.files.wordpress.com/2009/12/disabledcentraladmin1.jpg" medium="image">
			<media:title type="html">disabledCentralAdmin</media:title>
		</media:content>

		<media:content url="http://socialsp.files.wordpress.com/2009/12/enabledcentraladmin.jpg" medium="image">
			<media:title type="html">enabledCentralAdmin</media:title>
		</media:content>
	</item>
	</channel>
</rss>
