<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://www.dotnetmafia.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Corey Roth [MVP] : Visual Studio 2010, WebPart, SharePoint 2010</title><link>http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/Visual+Studio+2010/WebPart/SharePoint+2010/default.aspx</link><description>Tags: Visual Studio 2010, WebPart, SharePoint 2010</description><dc:language>en</dc:language><generator>CommunityServer 2007.1 (Build: 20917.1142)</generator><item><title>Slides from my SharePoint 2010 Development Talk at SharePoint Saturday Houston 2011</title><link>http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2011/05/16/slides-from-my-sharepoint-2010-development-talk-at-sharepoint-saturday-houston-2011.aspx</link><pubDate>Mon, 16 May 2011 19:34:37 GMT</pubDate><guid isPermaLink="false">ceb7fe2a-c56b-4d85-99e6-8dd548580538:4686</guid><dc:creator>CoreyRoth</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.dotnetmafia.com/blogs/dotnettipoftheday/rsscomments.aspx?PostID=4686</wfw:commentRss><comments>http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2011/05/16/slides-from-my-sharepoint-2010-development-talk-at-sharepoint-saturday-houston-2011.aspx#comments</comments><description>&lt;p&gt;Sorry, I’ve been slacking.&amp;#160; I’m a full week behind on posting my slides from &lt;a href="http://www.sharepointsaturday.org/houston/default.aspx"&gt;SharePoint Saturday Houston 2011&lt;/a&gt;.&amp;#160; This SharePoint Saturday was certainly unforgettable and I had a great time both attending and speaking.&amp;#160; I presented my Beginning SharePoint 2010 Development talk to a room packed full of people.&amp;#160; The turnout for the event was great.&amp;#160; Many thanks again to the master mind &lt;a href="http://twitter.com/victor_chat"&gt;@Victor_Chat&lt;/a&gt; and all of the great people &lt;a href="http://www.h-spug.org"&gt;H-SPUG&lt;/a&gt; for putting the event on.&amp;#160; I had a great time.&amp;#160; I’ve uploaded the slide deck to SlideShare for your reference.&amp;#160; I’ve also provided links to my relevant blog posts which will help get you started with SharePoint 2010 development.&amp;#160; If you have additional questions, feel free to ask.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.slideshare.net/CoreyRoth/sharepoint-2010-development-for-aspnet-developers-sharepoint-saturday-houston-2011"&gt;Beginning SharePoint 2010 Development for ASP.NET Developers Slide Deck&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2010/02/15/intro-to-sharepoint-2010-development-how-to-build-and-deploy-a-web-part.aspx"&gt;Intro to SharePoint 2010 Development: How to Build and Deploy a Web Part&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2008/10/22/intro-to-sharepoint-development-how-to-build-and-deploy-a-web-part.aspx"&gt;Intro to SharePoint Development: How to Build and Deploy a Web Part&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2011/04/01/office-365-how-to-build-and-deploy-a-web-part-with-sharepoint-online.aspx"&gt;Office 365 How to: Build and Deploy a Web Part with SharePoint Online&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Follow me on twitter &lt;a href="http://twitter.com/coreyroth"&gt;@coreyroth&lt;/a&gt;.&lt;/p&gt;&lt;img src="http://www.dotnetmafia.com/aggbug.aspx?PostID=4686" width="1" height="1"&gt;</description><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/SharePoint/default.aspx">SharePoint</category><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/WebPart/default.aspx">WebPart</category><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/Visual+Studio+2010/default.aspx">Visual Studio 2010</category><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/SharePoint+2010/default.aspx">SharePoint 2010</category><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/SharePoint+Saturday/default.aspx">SharePoint Saturday</category><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/H-SPUG/default.aspx">H-SPUG</category></item><item><title>Office 365 How to: Build and Deploy a Web Part with SharePoint Online</title><link>http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2011/04/01/office-365-how-to-build-and-deploy-a-web-part-with-sharepoint-online.aspx</link><pubDate>Fri, 01 Apr 2011 16:08:28 GMT</pubDate><guid isPermaLink="false">ceb7fe2a-c56b-4d85-99e6-8dd548580538:4521</guid><dc:creator>CoreyRoth</dc:creator><slash:comments>20</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.dotnetmafia.com/blogs/dotnettipoftheday/rsscomments.aspx?PostID=4521</wfw:commentRss><comments>http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2011/04/01/office-365-how-to-build-and-deploy-a-web-part-with-sharepoint-online.aspx#comments</comments><description>&lt;p&gt;You know by now that the cloud is hot and Microsoft says “we’re all in”.&amp;#160; That being said, there has never been a better time to push all of those chips forward and&amp;#160; jump on the bandwagon.&amp;#160; It’s time to get some experience with SharePoint Online / Office 365.&amp;#160; I know most people don’t have access to the Office 365 beta yet, but when it opens up, you should sign up for the public beta and start getting familiar with it.&amp;#160; If you haven’t seen SharePoint Online yet, check our my previous &lt;a href="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2011/03/07/a-quick-look-at-sharepoint-online-in-office-365.aspx"&gt;article&lt;/a&gt; which gives a quick tour of it.&amp;#160; I plan to write more about SharePoint Online in the future, so I figured the best place to start is with an introductory development article on building and deploying a web part.&amp;#160; My past series on building and deploying web parts to &lt;a href="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2010/02/15/intro-to-sharepoint-2010-development-how-to-build-and-deploy-a-web-part.aspx"&gt;2010&lt;/a&gt; and &lt;a href="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2008/10/22/intro-to-sharepoint-development-how-to-build-and-deploy-a-web-part.aspx"&gt;2007&lt;/a&gt; are still the most popular articles on DotNetMafia.com.&amp;#160; Let’s take what we learned there and see how we deploy web parts to the cloud.&lt;/p&gt;  &lt;p&gt;Before we get started, let’s reiterate what we’re working with.&amp;#160; With Office 365, your development scenario involves sandboxed solutions.&amp;#160; As you know, these solutions are deployed to the site collection level and offer a restricted subset of the SharePoint API.&amp;#160; If you are already confortable working with sandboxed solutions, you are in great shape to begin SharePoint Online development.&lt;/p&gt;  &lt;p&gt;What does the development environment look like?&amp;#160; Well, you know that SharePoint 2010 VM you already have?&amp;#160; You’re looking at it.&amp;#160; Just like Azure, SharePoint Online development also used the “Over the fence” development methodology.&amp;#160; Meaning, you develop your code locally and then throw it over the fence and hope it works.&amp;#160; This may sound bad, but it’s really not a big deal and the Azure people have been doing it for a while.&amp;#160; AppFabric is close to Azure, but there is always a possibility of differences when you get it in the cloud.&amp;#160; As long as you build a sandboxed solution and don’t make use of unsupported features (i.e.: PerformancePoint, BCS, etc), more than likely your code will work when it gets to the cloud.&amp;#160; There may be things that you can do in a Sandboxed solution in SharePoint 2010 compared to SharePoint Online, but it’s far too early to tell at this point.&amp;#160; To get started developing web parts in the cloud, you pretty much need a copy of SharePoint 2010 (or SharePoint Foundation) installed somewhere locally.&amp;#160; This could be native on your Windows 7 machine or inside a virtual machine.&amp;#160; Wherever it is, you will obviously need Internet access to get your code to the cloud.&lt;/p&gt;  &lt;p&gt;To get started developing in the cloud, the first step is to build the web part on your local SharePoint environment.&amp;#160; I won’t go through all the steps here, because most of them are the same from my article on &lt;a href="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2010/02/15/intro-to-sharepoint-2010-development-how-to-build-and-deploy-a-web-part.aspx"&gt;2010 Web Part Development&lt;/a&gt;.&amp;#160; However, I will go through the important steps.&amp;#160; The first step is to create a new Empty SharePoint 2010 Project in Visual Studio 2010.&amp;#160; Specify the URL to a local site on your SharePoint server.&amp;#160; Don’t use the address of your SharePoint Online site.&amp;#160; It won’t work.&amp;#160; When prompted for the solution type, choose Sandboxed Solution.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.dotnetmafia.com/blogs/dotnettipoftheday/SPOVisualStudioSandboxedSolution_462C7AE2.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="SPOVisualStudioSandboxedSolution" border="0" alt="SPOVisualStudioSandboxedSolution" src="http://www.dotnetmafia.com/blogs/dotnettipoftheday/SPOVisualStudioSandboxedSolution_thumb_7098ABFF.png" width="463" height="364" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;At this point, you have a regular SharePoint project in Visual Studio.&amp;#160; Add a web part to the project just like you would in SharePoint 2010.&amp;#160; Sticking with the Hello World type example, we put some code like the following in our web part.&lt;/p&gt; &lt;strong&gt;   &lt;div style="font-family:consolas;background:white;color:black;font-size:10pt;"&gt;     &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;using&lt;/span&gt; System;&lt;/p&gt;      &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;using&lt;/span&gt; System.ComponentModel;&lt;/p&gt;      &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;using&lt;/span&gt; System.Web;&lt;/p&gt;      &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;using&lt;/span&gt; System.Web.UI;&lt;/p&gt;      &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;using&lt;/span&gt; System.Web.UI.WebControls;&lt;/p&gt;      &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;using&lt;/span&gt; System.Web.UI.WebControls.WebParts;&lt;/p&gt;      &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;using&lt;/span&gt; Microsoft.SharePoint;&lt;/p&gt;      &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;using&lt;/span&gt; Microsoft.SharePoint.WebControls;&lt;/p&gt;      &lt;p style="margin:0px;"&gt;&amp;#160;&lt;/p&gt;      &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;namespace&lt;/span&gt; SharePointOnlineProject3.HelloCloudWebPart&lt;/p&gt;      &lt;p style="margin:0px;"&gt;{&lt;/p&gt;      &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; [&lt;span style="color:#2b91af;"&gt;ToolboxItemAttribute&lt;/span&gt;(&lt;span style="color:blue;"&gt;false&lt;/span&gt;)]&lt;/p&gt;      &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color:blue;"&gt;class&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;HelloCloudWebPart&lt;/span&gt; : &lt;span style="color:#2b91af;"&gt;WebPart&lt;/span&gt;&lt;/p&gt;      &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; {&lt;/p&gt;      &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:blue;"&gt;protected&lt;/span&gt; &lt;span style="color:blue;"&gt;override&lt;/span&gt; &lt;span style="color:blue;"&gt;void&lt;/span&gt; CreateChildControls()&lt;/p&gt;      &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {&lt;/p&gt;      &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Controls.Add(&lt;span style="color:blue;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;Label&lt;/span&gt;() { Text = &lt;span style="color:#a31515;"&gt;&amp;quot;Hello, Cloud!&amp;quot;&lt;/span&gt; });&lt;/p&gt;      &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }&lt;/p&gt;      &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; }&lt;/p&gt;      &lt;p style="margin:0px;"&gt;} &lt;/p&gt;   &lt;/div&gt; &lt;/strong&gt;  &lt;p&gt;At this point, we can test our code locally on our SharePoint server.&amp;#160; Build and deploy the project and then add your web part to a test page on your site.&amp;#160; Again, if you aren’t familiar with these steps, take a look at my &lt;a href="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2010/02/15/intro-to-sharepoint-2010-development-how-to-build-and-deploy-a-web-part.aspx"&gt;Building and Deploying Web Parts with SharePoint 2010&lt;/a&gt; post. If the code, works you should see a similar page like the one below.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.dotnetmafia.com/blogs/dotnettipoftheday/SPOHelloCloudWebPartLocal_3DC8A58B.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="SPOHelloCloudWebPartLocal" border="0" alt="SPOHelloCloudWebPartLocal" src="http://www.dotnetmafia.com/blogs/dotnettipoftheday/SPOHelloCloudWebPartLocal_thumb_04459594.png" width="517" height="318" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Now, we’re ready to send our web part “to the cloud!”.&amp;#160; How do we do that?&amp;#160; Start by using the Package menu to build a SharePoint package (.wsp file).&amp;#160; &lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.dotnetmafia.com/blogs/dotnettipoftheday/SPOVisualStudioPackageSolution_35D10329.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="SPOVisualStudioPackageSolution" border="0" alt="SPOVisualStudioPackageSolution" src="http://www.dotnetmafia.com/blogs/dotnettipoftheday/SPOVisualStudioPackageSolution_thumb_6E7BAD36.png" width="412" height="205" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;This creates a .wsp file located in the bin folder of the project.&amp;#160; We’ll use this file to deploy our web part to the cloud.&amp;#160; It’s now time to open up a browser and connect to your instance of SharePoint Online.&amp;#160; Once you get there, we deploy a sandboxed solution just like we would on-premises.&amp;#160; Go to Site Settings –&amp;gt; Solutions to view the Solutions Gallery.&amp;#160; Click on the &lt;em&gt;Solutions&lt;/em&gt; button in the ribbon, and then click &lt;em&gt;Upload Solution&lt;/em&gt;.&amp;#160; Browse to the bin folder of your Visual Studio project and select the file ending in .wsp.&amp;#160; Once it uploads, be sure and click the &lt;em&gt;Activate &lt;/em&gt;button.&amp;#160; &lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.dotnetmafia.com/blogs/dotnettipoftheday/SPOSolutionActivate_34F89D3F.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="SPOSolutionActivate" border="0" alt="SPOSolutionActivate" src="http://www.dotnetmafia.com/blogs/dotnettipoftheday/SPOSolutionActivate_thumb_6279BD02.png" width="383" height="221" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Now, you just need to ensure the feature is activated by going to Site Settings –&amp;gt; Site Collection Features.&amp;#160; If it is not activated, click the activate button.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.dotnetmafia.com/blogs/dotnettipoftheday/SPOFeatureActivated_2D00FADD.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="SPOFeatureActivated" border="0" alt="SPOFeatureActivated" src="http://www.dotnetmafia.com/blogs/dotnettipoftheday/SPOFeatureActivated_thumb_4CAFD4A5.png" width="443" height="28" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Your web part has now been thrown over the fence and deployed to the cloud!&amp;#160; Test it out by going to any page on the site and adding the web part to the page.&amp;#160; You’ll find your web part in the &lt;em&gt;Custom&lt;/em&gt; section by default.&amp;#160; If all goes well, your web part should work here too.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.dotnetmafia.com/blogs/dotnettipoftheday/SPOHelloCloudWebPartCloud_6C5EAE6D.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="SPOHelloCloudWebPartCloud" border="0" alt="SPOHelloCloudWebPartCloud" src="http://www.dotnetmafia.com/blogs/dotnettipoftheday/SPOHelloCloudWebPartCloud_thumb_60C8F12E.png" width="365" height="297" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Congratulations, you have now deployed code to the cloud!&amp;#160; It’s really not that hard is it?&amp;#160; Now, you might be wondering if you can debug your solution.&amp;#160; Unfortunately, the answer is no.&amp;#160; If you have an issue, you have to step through it locally on your on-premises SharePoint server.&amp;#160; That’s all there is to getting started with SharePoint Online development.&amp;#160; As you can see it’s very familiar to sandboxed solutions development with your on-premises server.&lt;/p&gt;&lt;img src="http://www.dotnetmafia.com/aggbug.aspx?PostID=4521" width="1" height="1"&gt;</description><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/SharePoint/default.aspx">SharePoint</category><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/WebPart/default.aspx">WebPart</category><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/Visual+Studio+2010/default.aspx">Visual Studio 2010</category><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/SharePoint+2010/default.aspx">SharePoint 2010</category><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/SharePoint+Online/default.aspx">SharePoint Online</category><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/Office+365/default.aspx">Office 365</category><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/Office+365+Grid/default.aspx">Office 365 Grid</category></item><item><title>Visual Web Parts in MOSS 2007</title><link>http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2010/07/16/visual-web-parts-in-moss-2007.aspx</link><pubDate>Fri, 16 Jul 2010 19:01:14 GMT</pubDate><guid isPermaLink="false">ceb7fe2a-c56b-4d85-99e6-8dd548580538:3718</guid><dc:creator>CoreyRoth</dc:creator><slash:comments>2</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.dotnetmafia.com/blogs/dotnettipoftheday/rsscomments.aspx?PostID=3718</wfw:commentRss><comments>http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2010/07/16/visual-web-parts-in-moss-2007.aspx#comments</comments><description>&lt;p&gt;Yesterday, I showed you how to deploy a regular web part to MOSS 2007 / WSS3 that was built and packaged in &lt;a href="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2010/07/15/using-visual-studio-2010-sharepoint-templates-to-deploy-a-web-part-in-sharepoint-2007.aspx"&gt;Visual Studio 2010&lt;/a&gt;.&amp;#160; Today, we can take that a step further and take advantage of the new Visual Web Part and deploy it the same way.&amp;#160; If you remember, a Visual Web Part is nothing more than a &lt;a href="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2009/10/20/introducing-the-visual-web-part-in-sharepoint-2010.aspx"&gt;glorified user control&lt;/a&gt;.&amp;#160; To get started, create a new empty SharePoint project or use and existing one.&amp;#160; If you need assistance with that, look at yesterday’s &lt;a href="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2010/07/15/using-visual-studio-2010-sharepoint-templates-to-deploy-a-web-part-in-sharepoint-2007.aspx"&gt;post&lt;/a&gt;.&amp;#160; Then, go ahead and create a new Visual Web Part.&amp;#160; The user control Visual Studio creates has many references to SharePoint 2010 DLLs that we simply do not need (or can use).&amp;#160; These must be removed.&amp;#160; Here is what it looks like when we start.&lt;/p&gt;  &lt;div style="font-family:consolas;background:white;color:black;font-size:10pt;"&gt;   &lt;p style="margin:0px;"&gt;&lt;span style="background:yellow;"&gt;&amp;lt;%&lt;/span&gt;&lt;span style="color:blue;"&gt;@&lt;/span&gt; &lt;span style="color:maroon;"&gt;Assembly&lt;/span&gt; &lt;span style="color:red;"&gt;Name&lt;/span&gt;&lt;span style="color:blue;"&gt;=&amp;quot;$SharePoint.Project.AssemblyFullName$&amp;quot;&lt;/span&gt; &lt;span style="background:yellow;"&gt;%&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="background:yellow;"&gt;&amp;lt;%&lt;/span&gt;&lt;span style="color:blue;"&gt;@&lt;/span&gt; &lt;span style="color:maroon;"&gt;Assembly&lt;/span&gt; &lt;span style="color:red;"&gt;Name&lt;/span&gt;&lt;span style="color:blue;"&gt;=&amp;quot;Microsoft.Web.CommandUI, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c&amp;quot;&lt;/span&gt; &lt;span style="background:yellow;"&gt;%&amp;gt;&lt;/span&gt; &lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="background:yellow;"&gt;&amp;lt;%&lt;/span&gt;&lt;span style="color:blue;"&gt;@&lt;/span&gt; &lt;span style="color:maroon;"&gt;Register&lt;/span&gt; &lt;span style="color:red;"&gt;Tagprefix&lt;/span&gt;&lt;span style="color:blue;"&gt;=&amp;quot;SharePoint&amp;quot;&lt;/span&gt; &lt;span style="color:red;"&gt;Namespace&lt;/span&gt;&lt;span style="color:blue;"&gt;=&amp;quot;Microsoft.SharePoint.WebControls&amp;quot;&lt;/span&gt; &lt;span style="color:red;"&gt;Assembly&lt;/span&gt;&lt;span style="color:blue;"&gt;=&amp;quot;Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c&amp;quot;&lt;/span&gt; &lt;span style="background:yellow;"&gt;%&amp;gt;&lt;/span&gt; &lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="background:yellow;"&gt;&amp;lt;%&lt;/span&gt;&lt;span style="color:blue;"&gt;@&lt;/span&gt; &lt;span style="color:maroon;"&gt;Register&lt;/span&gt; &lt;span style="color:red;"&gt;Tagprefix&lt;/span&gt;&lt;span style="color:blue;"&gt;=&amp;quot;Utilities&amp;quot;&lt;/span&gt; &lt;span style="color:red;"&gt;Namespace&lt;/span&gt;&lt;span style="color:blue;"&gt;=&amp;quot;Microsoft.SharePoint.Utilities&amp;quot;&lt;/span&gt; &lt;span style="color:red;"&gt;Assembly&lt;/span&gt;&lt;span style="color:blue;"&gt;=&amp;quot;Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c&amp;quot;&lt;/span&gt; &lt;span style="background:yellow;"&gt;%&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="background:yellow;"&gt;&amp;lt;%&lt;/span&gt;&lt;span style="color:blue;"&gt;@&lt;/span&gt; &lt;span style="color:maroon;"&gt;Register&lt;/span&gt; &lt;span style="color:red;"&gt;Tagprefix&lt;/span&gt;&lt;span style="color:blue;"&gt;=&amp;quot;asp&amp;quot;&lt;/span&gt; &lt;span style="color:red;"&gt;Namespace&lt;/span&gt;&lt;span style="color:blue;"&gt;=&amp;quot;System.Web.UI&amp;quot;&lt;/span&gt; &lt;span style="color:red;"&gt;Assembly&lt;/span&gt;&lt;span style="color:blue;"&gt;=&amp;quot;System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35&amp;quot;&lt;/span&gt; &lt;span style="background:yellow;"&gt;%&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="background:yellow;"&gt;&amp;lt;%&lt;/span&gt;&lt;span style="color:blue;"&gt;@&lt;/span&gt; &lt;span style="color:maroon;"&gt;Import&lt;/span&gt; &lt;span style="color:red;"&gt;Namespace&lt;/span&gt;&lt;span style="color:blue;"&gt;=&amp;quot;Microsoft.SharePoint&amp;quot;&lt;/span&gt; &lt;span style="background:yellow;"&gt;%&amp;gt;&lt;/span&gt; &lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="background:yellow;"&gt;&amp;lt;%&lt;/span&gt;&lt;span style="color:blue;"&gt;@&lt;/span&gt; &lt;span style="color:maroon;"&gt;Register&lt;/span&gt; &lt;span style="color:red;"&gt;Tagprefix&lt;/span&gt;&lt;span style="color:blue;"&gt;=&amp;quot;WebPartPages&amp;quot;&lt;/span&gt; &lt;span style="color:red;"&gt;Namespace&lt;/span&gt;&lt;span style="color:blue;"&gt;=&amp;quot;Microsoft.SharePoint.WebPartPages&amp;quot;&lt;/span&gt; &lt;span style="color:red;"&gt;Assembly&lt;/span&gt;&lt;span style="color:blue;"&gt;=&amp;quot;Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c&amp;quot;&lt;/span&gt; &lt;span style="background:yellow;"&gt;%&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="background:yellow;"&gt;&amp;lt;%&lt;/span&gt;&lt;span style="color:blue;"&gt;@&lt;/span&gt; &lt;span style="color:maroon;"&gt;Control&lt;/span&gt; &lt;span style="color:red;"&gt;Language&lt;/span&gt;&lt;span style="color:blue;"&gt;=&amp;quot;C#&amp;quot;&lt;/span&gt; &lt;span style="color:red;"&gt;AutoEventWireup&lt;/span&gt;&lt;span style="color:blue;"&gt;=&amp;quot;true&amp;quot;&lt;/span&gt; &lt;span style="color:red;"&gt;CodeBehind&lt;/span&gt;&lt;span style="color:blue;"&gt;=&amp;quot;VisualWebPart1UserControl.ascx.cs&amp;quot;&lt;/span&gt; &lt;span style="color:red;"&gt;Inherits&lt;/span&gt;&lt;span style="color:blue;"&gt;=&amp;quot;WSSWebPart.VisualWebPart1.VisualWebPart1UserControl&amp;quot;&lt;/span&gt; &lt;span style="background:yellow;"&gt;%&amp;gt;&lt;/span&gt;&amp;#160;&lt;/p&gt; &lt;/div&gt;   &lt;p&gt;Remove any reference to a SharePoint version 14 DLL and you will have a file that looks like this.&amp;#160; Then I’m just going to add a simple label to demonstrate our user control.&amp;#160; Here is what it looks like after the changes.&lt;/p&gt;  &lt;div style="font-family:consolas;background:white;color:black;font-size:10pt;"&gt;   &lt;p style="margin:0px;"&gt;&lt;span style="background:yellow;"&gt;&amp;lt;%&lt;/span&gt;&lt;span style="color:blue;"&gt;@&lt;/span&gt; &lt;span style="color:maroon;"&gt;Assembly&lt;/span&gt; &lt;span style="color:red;"&gt;Name&lt;/span&gt;&lt;span style="color:blue;"&gt;=&amp;quot;$SharePoint.Project.AssemblyFullName$&amp;quot;&lt;/span&gt; &lt;span style="background:yellow;"&gt;%&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="background:yellow;"&gt;&amp;lt;%&lt;/span&gt;&lt;span style="color:blue;"&gt;@&lt;/span&gt; &lt;span style="color:maroon;"&gt;Register&lt;/span&gt; &lt;span style="color:red;"&gt;Tagprefix&lt;/span&gt;&lt;span style="color:blue;"&gt;=&amp;quot;asp&amp;quot;&lt;/span&gt; &lt;span style="color:red;"&gt;Namespace&lt;/span&gt;&lt;span style="color:blue;"&gt;=&amp;quot;System.Web.UI&amp;quot;&lt;/span&gt; &lt;span style="color:red;"&gt;Assembly&lt;/span&gt;&lt;span style="color:blue;"&gt;=&amp;quot;System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35&amp;quot;&lt;/span&gt; &lt;span style="background:yellow;"&gt;%&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="background:yellow;"&gt;&amp;lt;%&lt;/span&gt;&lt;span style="color:blue;"&gt;@&lt;/span&gt; &lt;span style="color:maroon;"&gt;Import&lt;/span&gt; &lt;span style="color:red;"&gt;Namespace&lt;/span&gt;&lt;span style="color:blue;"&gt;=&amp;quot;Microsoft.SharePoint&amp;quot;&lt;/span&gt; &lt;span style="background:yellow;"&gt;%&amp;gt;&lt;/span&gt; &lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="background:yellow;"&gt;&amp;lt;%&lt;/span&gt;&lt;span style="color:blue;"&gt;@&lt;/span&gt; &lt;span style="color:maroon;"&gt;Control&lt;/span&gt; &lt;span style="color:red;"&gt;Language&lt;/span&gt;&lt;span style="color:blue;"&gt;=&amp;quot;C#&amp;quot;&lt;/span&gt; &lt;span style="color:red;"&gt;AutoEventWireup&lt;/span&gt;&lt;span style="color:blue;"&gt;=&amp;quot;true&amp;quot;&lt;/span&gt; &lt;span style="color:red;"&gt;CodeBehind&lt;/span&gt;&lt;span style="color:blue;"&gt;=&amp;quot;VisualWebPart1UserControl.ascx.cs&amp;quot;&lt;/span&gt; &lt;span style="color:red;"&gt;Inherits&lt;/span&gt;&lt;span style="color:blue;"&gt;=&amp;quot;WSSWebPart.VisualWebPart1.VisualWebPart1UserControl&amp;quot;&lt;/span&gt; &lt;span style="background:yellow;"&gt;%&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:maroon;"&gt;asp&lt;/span&gt;&lt;span style="color:blue;"&gt;:&lt;/span&gt;&lt;span style="color:maroon;"&gt;Label&lt;/span&gt; &lt;span style="color:red;"&gt;ID&lt;/span&gt;&lt;span style="color:blue;"&gt;=&amp;quot;MyLabel&amp;quot;&lt;/span&gt; &lt;span style="color:red;"&gt;runat&lt;/span&gt;&lt;span style="color:blue;"&gt;=&amp;quot;server&amp;quot;&lt;/span&gt; &lt;span style="color:red;"&gt;Text&lt;/span&gt;&lt;span style="color:blue;"&gt;=&amp;quot;Hello, world!&amp;#160; Visual Web Part compiled in Visual Studio 2010!&amp;quot;&lt;/span&gt; &lt;span style="color:blue;"&gt;/&amp;gt;&lt;/span&gt;&amp;#160;&lt;/p&gt; &lt;/div&gt;   &lt;p&gt;You can replace, the version 14 references with version 12 references if you really need them.&amp;#160; However, I find that most of the time, I am really only using standard ASP.NET controls so they are unnecessary.&amp;#160; That is all you have to do.&amp;#160; Assuming you started with a solution from yesterday, you can package the project and install the .wsp file on your SharePoint 2007 server using STSADM.&amp;#160; If you created a new project don’t forget to remember to remove the SharePoint version attribute in the Package properties (discussed in yesterday’s post).&amp;#160; Here is what my Visual Web Part looks like running on SharePoint 2007.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.dotnetmafia.com/blogs/dotnettipoftheday/VS2010WSS3VisualWebPartComplete_034503DA.png"&gt;&lt;img style="border-bottom:0px;border-left:0px;display:inline;border-top:0px;border-right:0px;" title="VS2010WSS3VisualWebPartComplete" border="0" alt="VS2010WSS3VisualWebPartComplete" src="http://www.dotnetmafia.com/blogs/dotnettipoftheday/VS2010WSS3VisualWebPartComplete_thumb_6D0EE887.png" width="686" height="174" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;It’s pretty simple to do.&amp;#160; I am able to leverage the simplicity of the Visual Web Part and take advantage of Visual Studio 2010 building my .wsp file.&amp;#160; The more I work with Visual Studio 2010, the more I realize I can use SharePoint Project Items in previous versions of SharePoint with just a little bit of work.&lt;/p&gt;&lt;img src="http://www.dotnetmafia.com/aggbug.aspx?PostID=3718" width="1" height="1"&gt;</description><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/SharePoint/default.aspx">SharePoint</category><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/WebPart/default.aspx">WebPart</category><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/Visual+Studio+2010/default.aspx">Visual Studio 2010</category><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/SharePoint+2010/default.aspx">SharePoint 2010</category></item><item><title>Using Visual Studio 2010 SharePoint Templates to deploy a web part in SharePoint 2007</title><link>http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2010/07/15/using-visual-studio-2010-sharepoint-templates-to-deploy-a-web-part-in-sharepoint-2007.aspx</link><pubDate>Thu, 15 Jul 2010 21:34:00 GMT</pubDate><guid isPermaLink="false">ceb7fe2a-c56b-4d85-99e6-8dd548580538:3704</guid><dc:creator>CoreyRoth</dc:creator><slash:comments>16</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.dotnetmafia.com/blogs/dotnettipoftheday/rsscomments.aspx?PostID=3704</wfw:commentRss><comments>http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2010/07/15/using-visual-studio-2010-sharepoint-templates-to-deploy-a-web-part-in-sharepoint-2007.aspx#comments</comments><description>&lt;p&gt;That’s a mouth full.&amp;#160; I always suspected it was possible to use Visual Studio 2010 to package up my SharePoint web parts and other artifacts into a solution (.wsp file) and turn around and deploy that code into MOSS 2007.&amp;#160; Today I gave it a try and it actually works pretty well.&amp;#160; This post will show you how to do it.&amp;#160; I will remind you that you won’t be able to take advantage of any of the automatic deployment, debugging features built into Visual Studio 2010 and SharePoint 2010, but you will have a nice solution file that was built automatically without having to use a third party tool like WSPBuilder.&amp;#160; You can then take the solution package and deploy it to SharePoint with stsadm.&lt;/p&gt;  &lt;p&gt;I will start off by using the SharePoint 2010 Empty Project Template.&amp;#160; Now, unfortunately, the wizard that starts this project has a dependency on SharePoint 2010.&amp;#160; It simply won’t run without it.&amp;#160; However, if you happen to already have a copy of a project that has been created, you can open an existing SharePoint 2010 project template on a computer that does not have SharePoint installed.&amp;#160; I have attached a copy of my Visual Studio solution for you to use as a starting point if you need it.&amp;#160; &lt;/p&gt;  &lt;p&gt;Once I have my project open, I proceed to create a web part as shown below in the Solution Explorer.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.dotnetmafia.com/blogs/dotnettipoftheday/VSS2010Wss3WebPartSolutionExplorer_4AC32A27.png"&gt;&lt;img style="border-bottom:0px;border-left:0px;display:inline;border-top:0px;border-right:0px;" title="VSS2010Wss3WebPartSolutionExplorer" border="0" alt="VSS2010Wss3WebPartSolutionExplorer" src="http://www.dotnetmafia.com/blogs/dotnettipoftheday/VSS2010Wss3WebPartSolutionExplorer_thumb_4186EEE6.png" width="211" height="244" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;I don’t have to make any modifications to the class.&amp;#160; So I add some simple “Hello, World!” code to it.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.dotnetmafia.com/blogs/dotnettipoftheday/VSS2010Wss3WebPartCode_40425607.png"&gt;&lt;img style="border-bottom:0px;border-left:0px;display:inline;border-top:0px;border-right:0px;" title="VSS2010Wss3WebPartCode" border="0" alt="VSS2010Wss3WebPartCode" src="http://www.dotnetmafia.com/blogs/dotnettipoftheday/VSS2010Wss3WebPartCode_thumb_10A4377B.png" width="555" height="296" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;We’re targeting SharePoint version 3, so that means we need to change some references.&amp;#160; All of the DLLs in SharePoint 2010 are version 14.&amp;#160; We need version 12 DLLs.&amp;#160; So what you will need to do is go get a copy of Microsoft.SharePoint.dll (and possibly Microsoft.SharePoint.Security.dll) from your version 3 SharePoint farm.&amp;#160; We then need to remove the reference to the version 14 DLLs.&amp;#160; Click on Microsoft.SharePoint.dll and Microsoft.SharePoint.Security.dll and remove them from the solution.&amp;#160; We then add our version 12 DLLs to the references list and we’re ready to compile our web part for WSS3.&amp;#160; &lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.dotnetmafia.com/blogs/dotnettipoftheday/VSS2010Wss3WebPartReferences_729603B9.png"&gt;&lt;img style="border-bottom:0px;border-left:0px;display:inline;border-top:0px;border-right:0px;" title="VSS2010Wss3WebPartReferences" border="0" alt="VSS2010Wss3WebPartReferences" src="http://www.dotnetmafia.com/blogs/dotnettipoftheday/VSS2010Wss3WebPartReferences_thumb_6DB34FFD.png" width="219" height="244" /&gt;&lt;/a&gt; &lt;a href="http://www.dotnetmafia.com/blogs/dotnettipoftheday/VSS2010Wss3WebPartReferencesProperties_5DC40B39.png"&gt;&lt;img style="border-bottom:0px;border-left:0px;display:inline;border-top:0px;border-right:0px;" title="VSS2010Wss3WebPartReferencesProperties" border="0" alt="VSS2010Wss3WebPartReferencesProperties" src="http://www.dotnetmafia.com/blogs/dotnettipoftheday/VSS2010Wss3WebPartReferencesProperties_thumb_6F346C11.png" width="209" height="244" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;At this point, I will remind you of the caveats of perusing this completely unsupported approach.&amp;#160; Obviously, you can’t need to make sure you are only using API calls from version 3.&amp;#160; Using a class from SharePoint 2010 is obviously not going to work.&lt;/p&gt;  &lt;p&gt;Build your project and it should compile successfully.&amp;#160; Now, I figured everything would work at this point but I discovered one thing that I had to change in this process.&amp;#160; The SharePoint 2010 solution schema has a new attribute called SharePoint version on the SharePoint element.&amp;#160; WSS3 does not like this.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.dotnetmafia.com/blogs/dotnettipoftheday/VSS2010Wss3WebPartManifest_4A36AB98.png"&gt;&lt;img style="border-bottom:0px;border-left:0px;display:inline;border-top:0px;border-right:0px;" title="VSS2010Wss3WebPartManifest" border="0" alt="VSS2010Wss3WebPartManifest" src="http://www.dotnetmafia.com/blogs/dotnettipoftheday/VSS2010Wss3WebPartManifest_thumb_3B1FCCBE.png" width="711" height="163" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Luckily, I discovered, that if we delete the value from the property window, it actually removes the attribute.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.dotnetmafia.com/blogs/dotnettipoftheday/VSS2010Wss3WebPartManifestProperties_45FCAE06.png"&gt;&lt;img style="border-bottom:0px;border-left:0px;display:inline;border-top:0px;border-right:0px;" title="VSS2010Wss3WebPartManifestProperties" border="0" alt="VSS2010Wss3WebPartManifestProperties" src="http://www.dotnetmafia.com/blogs/dotnettipoftheday/VSS2010Wss3WebPartManifestProperties_thumb_297FBC26.png" width="224" height="233" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Simply, remove the value there and we are ready to package the project.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.dotnetmafia.com/blogs/dotnettipoftheday/VSS2010Wss3WebPartPackage_4FE19F71.png"&gt;&lt;img style="border-bottom:0px;border-left:0px;display:inline;border-top:0px;border-right:0px;" title="VSS2010Wss3WebPartPackage" border="0" alt="VSS2010Wss3WebPartPackage" src="http://www.dotnetmafia.com/blogs/dotnettipoftheday/VSS2010Wss3WebPartPackage_thumb_1D1198FD.png" width="378" height="227" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;When this is complete, you can browse the file system and find your .wsp file in the bin folder.&amp;#160; Copy the .wsp file to the SharePoint 2007 server if you aren’t already on it.&amp;#160; Then add and deploy the package with stsadm.&amp;#160; At this point, you will have a feature that you can activate on your SharePoint 2007 server.&amp;#160; Go to site collection features and activate it.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.dotnetmafia.com/blogs/dotnettipoftheday/VSS2010Wss3WebPartCodeFeatureActivated_63225610.png"&gt;&lt;img style="border-bottom:0px;border-left:0px;display:inline;border-top:0px;border-right:0px;" title="VSS2010Wss3WebPartCodeFeatureActivated" border="0" alt="VSS2010Wss3WebPartCodeFeatureActivated" src="http://www.dotnetmafia.com/blogs/dotnettipoftheday/VSS2010Wss3WebPartCodeFeatureActivated_thumb_0D225439.png" width="607" height="26" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;The web part should now be in the Solution Gallery.&amp;#160; Now edit a page, and add a new web part.&amp;#160; Your web part should be in the group labeled &lt;em&gt;Custom&lt;/em&gt; assuming you haven’t changed it.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.dotnetmafia.com/blogs/dotnettipoftheday/VSS2010Wss3WebPartAdd_2BF8C817.png"&gt;&lt;img style="border-bottom:0px;border-left:0px;display:inline;border-top:0px;border-right:0px;" title="VSS2010Wss3WebPartAdd" border="0" alt="VSS2010Wss3WebPartAdd" src="http://www.dotnetmafia.com/blogs/dotnettipoftheday/VSS2010Wss3WebPartAdd_thumb_30FB05C6.png" width="244" height="148" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;We can now verify that the web part code works on the page.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.dotnetmafia.com/blogs/dotnettipoftheday/VSS2010Wss3WebPartComplete_1726CF97.png"&gt;&lt;img style="border-bottom:0px;border-left:0px;display:inline;border-top:0px;border-right:0px;" title="VSS2010Wss3WebPartComplete" border="0" alt="VSS2010Wss3WebPartComplete" src="http://www.dotnetmafia.com/blogs/dotnettipoftheday/VSS2010Wss3WebPartComplete_thumb_6CE6FBE1.png" width="559" height="237" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;As you can see it’s really pretty easy to build a WSS3 web part in Visual Studio 2010 and deploy it.&amp;#160; We lose some of the cool VS2010/SP2010 integration features of course, but the fact it builds the package for us is a huge win.&amp;#160; Not to mention, upgrading our code to work in SharePoint 2010 later will be pretty easy since all we have to do is change our references from the version 12 to the version 14 DLLs.&amp;#160; I’ve only covered how to do a web part here today.&amp;#160; I suspect other SharePoint Project Items will work as well.&amp;#160; I’ll try them out soon and let you know how they work.&amp;#160; As a reminder, I have attached a copy of my solution to this post for you to use in case you don’t have SharePoint 2010 installed any where.&amp;#160; Give it a try and let me know if it works for you.&lt;/p&gt;&lt;img src="http://www.dotnetmafia.com/aggbug.aspx?PostID=3704" width="1" height="1"&gt;</description><enclosure url="http://www.dotnetmafia.com/blogs/dotnettipoftheday/attachment/3704.ashx" length="3014409" type="application/x-zip-compressed" /><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/SharePoint/default.aspx">SharePoint</category><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/MOSS/default.aspx">MOSS</category><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/WebPart/default.aspx">WebPart</category><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/Visual+Studio+2010/default.aspx">Visual Studio 2010</category><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/SharePoint+2010/default.aspx">SharePoint 2010</category></item><item><title>Intro to SharePoint 2010 Development: How to Build and Deploy a Web Part</title><link>http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2010/02/15/intro-to-sharepoint-2010-development-how-to-build-and-deploy-a-web-part.aspx</link><pubDate>Mon, 15 Feb 2010 20:17:41 GMT</pubDate><guid isPermaLink="false">ceb7fe2a-c56b-4d85-99e6-8dd548580538:2748</guid><dc:creator>CoreyRoth</dc:creator><slash:comments>36</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.dotnetmafia.com/blogs/dotnettipoftheday/rsscomments.aspx?PostID=2748</wfw:commentRss><comments>http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2010/02/15/intro-to-sharepoint-2010-development-how-to-build-and-deploy-a-web-part.aspx#comments</comments><description>&lt;p&gt;If you are already familiar with SharePoint 2010, you already know how easy it is to build and deploy a web part now.&amp;#160; However, this post is for those that don’t keep up with SharePoint as some of us do and may not realize how the development experience has improved so much.&amp;#160; My post &lt;a href="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2008/10/22/intro-to-sharepoint-development-how-to-build-and-deploy-a-web-part.aspx"&gt;How to Build and Deploy a Web Part&lt;/a&gt; is by far the most popular post on DotNetMafia.com.&amp;#160; I wanted to make today’s post just as a point to show you how much less work is involved in deploying a web part.&amp;#160; I am going to group this post into sections in a similar manner as I did the post for the WSS3 post.&lt;/p&gt;  &lt;h5&gt;&lt;/h5&gt;  &lt;h5&gt;Environment&lt;/h5&gt;  &lt;p&gt;There can be entire talks about what the best way to develop is now, but we’ll start with the simplest.&amp;#160; Although you can install SharePoint on Windows 7 and directly develop on it, most people are going to say stick with a virtual machine and run Windows Server 2008 R2.&amp;#160; It’s certainly simpler to get all of the prerequisites installed if you stick with Windows Server.&amp;#160; The benefits to developing directly on a machine with SharePoint on it are so great now that I would recommend against &lt;a href="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2008/03/05/how-to-remote-debugging-a-web-application.aspx"&gt;remote debugging&lt;/a&gt; (although you still can).&amp;#160; The SharePoint Root (or the 12 hive as you called it) is now the &lt;a href="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2009/10/20/sharepoint-2010-12-hive-2-14-hive.aspx"&gt;14 hive&lt;/a&gt; and is located at the predictable path below.&lt;/p&gt;  &lt;p&gt;&lt;em&gt;C:\Program Files\Common Files\microsoft shared\Web Server Extensions\14&lt;/em&gt;&lt;/p&gt;  &lt;h5&gt;Coding the Web Part&lt;/h5&gt;  &lt;p&gt;Here is where things start to change.&amp;#160; Instead of creating a class library and adding references to the SharePoint DLLs, we simply use one of the new included SharePoint project templates as you can see here.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.dotnetmafia.com/blogs/dotnettipoftheday/WebPartIntroEmptyProject_43970EE2.png"&gt;&lt;img style="border-bottom:0px;border-left:0px;display:inline;border-top:0px;border-right:0px;" title="WebPartIntroEmptyProject" border="0" alt="WebPartIntroEmptyProject" src="http://www.dotnetmafia.com/blogs/dotnettipoftheday/WebPartIntroEmptyProject_thumb_138CBD61.png" width="519" height="369" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Start by using the Empty SharePoint Project template.&amp;#160; Also make sure you have it set to .NET Framework 3.5 as SharePoint does not run under .NET Framework 4.0 (don’t get me started).&amp;#160; You’ll notice you have many different project templates to choose from.&amp;#160; Most of these can also be used once you create an empty project.&amp;#160; On the next dialogue, pick farm solution.&amp;#160; I’ll go into the difference between sandboxed and farm solutions, but more than likely you are going to use farm solutions every time.&amp;#160; You also need to specify the URL to your server.&amp;#160; You can change that if you want but the default value will probably work for you in this case.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.dotnetmafia.com/blogs/dotnettipoftheday/WebPartIntroSolutionType_19D393EF.png"&gt;&lt;img style="border-bottom:0px;border-left:0px;display:inline;border-top:0px;border-right:0px;" title="WebPartIntroSolutionType" border="0" alt="WebPartIntroSolutionType" src="http://www.dotnetmafia.com/blogs/dotnettipoftheday/WebPartIntroSolutionType_thumb_4B5F0184.png" width="387" height="307" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;This gives us a solution that looks like this.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.dotnetmafia.com/blogs/dotnettipoftheday/WebPartIntroSolutionExplorer_06B26743.png"&gt;&lt;img style="border-bottom:0px;border-left:0px;display:inline;border-top:0px;border-right:0px;" title="WebPartIntroSolutionExplorer" border="0" alt="WebPartIntroSolutionExplorer" src="http://www.dotnetmafia.com/blogs/dotnettipoftheday/WebPartIntroSolutionExplorer_thumb_2661410B.png" width="163" height="156" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Now we are ready to build our new web part.&amp;#160; If you bring up the add new item context menu, you will see a number of choices for the types of new SharePoint Project Items (SPIs) that you can create.&amp;#160; We’re going to choose Web Part in this case.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.dotnetmafia.com/blogs/dotnettipoftheday/WebPartIntroSPI_6A357562.png"&gt;&lt;img style="border-bottom:0px;border-left:0px;display:inline;border-top:0px;border-right:0px;" title="WebPartIntroSPI" border="0" alt="WebPartIntroSPI" src="http://www.dotnetmafia.com/blogs/dotnettipoftheday/WebPartIntroSPI_thumb_28BAC309.png" width="532" height="378" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;What is the &lt;a href="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2009/10/20/introducing-the-visual-web-part-in-sharepoint-2010.aspx"&gt;Visual Web Part&lt;/a&gt; you ask?&amp;#160; That’s just a user control which relates directly to my second most popular post on &lt;a href="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2008/11/18/introduction-to-sharepoint-development-deploy-a-user-control-in-sharepoint.aspx"&gt;How to Deploy a User Control&lt;/a&gt;.&amp;#160; Now we’re finally ready to add some code.&amp;#160; We’re just going to take our code from the WSS3 post and use it here.&lt;/p&gt;  &lt;div style="font-family:consolas;background:black;color:white;font-size:13pt;font-weight:bold;"&gt;   &lt;p style="margin:0px;"&gt;&lt;span style="color:#cc7832;"&gt;using&lt;/span&gt; System;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="color:#cc7832;"&gt;using&lt;/span&gt; System.ComponentModel;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="color:#cc7832;"&gt;using&lt;/span&gt; System.Runtime.InteropServices;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="color:#cc7832;"&gt;using&lt;/span&gt; System.Web.UI;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="color:#cc7832;"&gt;using&lt;/span&gt; System.Web.UI.WebControls;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="color:#cc7832;"&gt;using&lt;/span&gt; System.Web.UI.WebControls.WebParts;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="color:#cc7832;"&gt;using&lt;/span&gt; Microsoft.SharePoint;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="color:#cc7832;"&gt;using&lt;/span&gt; Microsoft.SharePoint.WebControls;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="color:#cc7832;"&gt;namespace&lt;/span&gt; SharePointProject1.TestWebPart&lt;/p&gt;    &lt;p style="margin:0px;"&gt;{&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; [ToolboxItemAttribute(&lt;span style="color:#cc7832;"&gt;false&lt;/span&gt;)]&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:#cc7832;"&gt;public&lt;/span&gt; &lt;span style="color:#cc7832;"&gt;class&lt;/span&gt; &lt;span style="color:#ffc66d;"&gt;TestWebPart&lt;/span&gt; : WebPart&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; {&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:#cc7832;"&gt;public&lt;/span&gt; TestWebPart()&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:#cc7832;"&gt;protected&lt;/span&gt; &lt;span style="color:#cc7832;"&gt;override&lt;/span&gt; &lt;span style="color:#cc7832;"&gt;void&lt;/span&gt; CreateChildControls()&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:#cc7832;"&gt;base&lt;/span&gt;&lt;span style="font-weight:normal;"&gt;.CreateChildControls();&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Controls.Add(&lt;span style="color:#cc7832;"&gt;new&lt;/span&gt; Label() { Text = &lt;span style="color:#a5c25c;"&gt;&amp;quot;My Test SharePoint 2010 Web Part (Hello World)!&amp;quot;&lt;/span&gt; });&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:#cc7832;"&gt;protected&lt;/span&gt; &lt;span style="color:#cc7832;"&gt;override&lt;/span&gt; &lt;span style="color:#cc7832;"&gt;void&lt;/span&gt; RenderContents(HtmlTextWriter writer)&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:#cc7832;"&gt;base&lt;/span&gt;&lt;span style="font-weight:normal;"&gt;.RenderContents(writer);&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; }&lt;/p&gt;    &lt;p style="margin:0px;"&gt;}&lt;/p&gt; &lt;/div&gt;   &lt;p&gt;The only line of code I added here was the line to add the label and set its text.&amp;#160; Everything else came from the template.&lt;/p&gt;  &lt;h5&gt;Describing the Web Part&lt;/h5&gt;  &lt;p&gt;In my WSS3 post, this is where I talked about building a .webpart file.&amp;#160; Well, you don’t need to worry about that any more as Visual Studio creates it for you.&amp;#160; Here is what solution explorer looks like after you add your first web part.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.dotnetmafia.com/blogs/dotnettipoftheday/WebPartIntroSolutionExplorer2_43F31C0A.png"&gt;&lt;img style="border-bottom:0px;border-left:0px;display:inline;border-top:0px;border-right:0px;" title="WebPartIntroSolutionExplorer2" border="0" alt="WebPartIntroSolutionExplorer2" src="http://www.dotnetmafia.com/blogs/dotnettipoftheday/WebPartIntroSolutionExplorer2_thumb_7C9DC617.png" width="213" height="244" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;As you can see the .webpart file is already there as well as an elements.xml file for a feature to deploy the web part.&amp;#160; The WSS3 post went on to talk about all of the things you need to know about building a feature.&amp;#160; This is still good stuff to know, but its already taken care of for you.&amp;#160; If you want to edit the basic feature information, just open it up in solution explorer and you get a nice new interface that looks like this.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.dotnetmafia.com/blogs/dotnettipoftheday/WebPartIntroFeatureEditor_152D6368.png"&gt;&lt;img style="border-bottom:0px;border-left:0px;display:inline;border-top:0px;border-right:0px;" title="WebPartIntroFeatureEditor" border="0" alt="WebPartIntroFeatureEditor" src="http://www.dotnetmafia.com/blogs/dotnettipoftheday/WebPartIntroFeatureEditor_thumb_14C13073.png" width="390" height="227" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;I’m not going to waste space showing you the insides of the files it creates for you.&amp;#160; Just know it creates them for you and it saves you a ton of time.&lt;/p&gt;  &lt;h5&gt;Deploying via Solution Package&lt;/h5&gt;  &lt;p&gt;In my WSS3 post, I explained how to create a cab.ddf and manifest.xml file.&amp;#160; Well guest what?&amp;#160; That is taken care of for you now as well.&amp;#160; The Package.package file in the solution explorer provides another nice editor which allows you to choose with files go into the package.&amp;#160; You don’t have to keep track of a thing any more, it just builds the package and takes care of it for you.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.dotnetmafia.com/blogs/dotnettipoftheday/WebPartIntroPackageEditor_42425036.png"&gt;&lt;img style="border-bottom:0px;border-left:0px;display:inline;border-top:0px;border-right:0px;" title="WebPartIntroPackageEditor" border="0" alt="WebPartIntroPackageEditor" src="http://www.dotnetmafia.com/blogs/dotnettipoftheday/WebPartIntroPackageEditor_thumb_2CE49ACE.png" width="391" height="191" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;At this point, Visual Studio has created the .webpart file, the feature, and the solution package.&amp;#160; However, we still need to deploy it and if we could debug it that would be even cooler right?&amp;#160; Take a look at our new options in the Build menu.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.dotnetmafia.com/blogs/dotnettipoftheday/WebPartIntroBuildMenu_4574381E.png"&gt;&lt;img style="border-bottom:0px;border-left:0px;display:inline;border-top:0px;border-right:0px;" title="WebPartIntroBuildMenu" border="0" alt="WebPartIntroBuildMenu" src="http://www.dotnetmafia.com/blogs/dotnettipoftheday/WebPartIntroBuildMenu_thumb_59F9879C.png" width="244" height="192" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;   &lt;p&gt;We can build and rebuild just like any other project, but notice the options for Deploy, Package, and Retract.&amp;#160; Those are all SharePoint functions.&amp;#160; In this case, I want to deploy my solution.&amp;#160; Choosing deploy, we see the following in the output window.&lt;/p&gt;    &lt;p&gt;------ Build started: Project: SharePointProject1, Configuration: Debug Any CPU ------     &lt;br /&gt;&amp;#160; SharePointProject1 -&amp;gt; C:\Code\SharePointProject1\bin\Debug\SharePointProject1.dll      &lt;br /&gt;&amp;#160; Successfully created package at: C:\Code\SharePointProject1\bin\Debug\SharePointProject1.wsp      &lt;br /&gt;------ Deploy started: Project: SharePointProject1, Configuration: Debug Any CPU ------      &lt;br /&gt;Active Deployment Configuration: Default      &lt;br /&gt;Run Pre-Deployment Command:      &lt;br /&gt;&amp;#160; Skipping deployment step because a pre-deployment command is not specified.      &lt;br /&gt;Recycle IIS Application Pool:      &lt;br /&gt;&amp;#160; Recycling IIS application pool &amp;#39;SharePoint - 80&amp;#39;...      &lt;br /&gt;Retract Solution:      &lt;br /&gt;&amp;#160; Skipping package retraction because no matching package on the server was found.      &lt;br /&gt;Add Solution:      &lt;br /&gt;&amp;#160; Adding solution &amp;#39;SharePointProject1.wsp&amp;#39;...      &lt;br /&gt;&amp;#160; Deploying solution &amp;#39;SharePointProject1.wsp&amp;#39;...      &lt;br /&gt;Activate Features:      &lt;br /&gt;&amp;#160; Activating feature &amp;#39;Feature1&amp;#39; ...      &lt;br /&gt;Run Post-Deployment Command:      &lt;br /&gt;&amp;#160; Skipping deployment step because a post-deployment command is not specified.      &lt;br /&gt;========== Build: 1 succeeded or up-to-date, 0 failed, 0 skipped ==========      &lt;br /&gt;========== Deploy: 1 succeeded, 0 failed, 0 skipped ==========      &lt;br /&gt;&lt;/p&gt;    &lt;p&gt;From inspecting the text of the log, you can see that Visual Studio compiled, created a package, reset my Application Pool, Added the Solution, Deployed the Solution, and activated the feature.&amp;#160; Let’s check SharePoint and see if it’s really there.&lt;/p&gt;    &lt;p&gt;&lt;a href="http://www.dotnetmafia.com/blogs/dotnettipoftheday/WebPartIntroGallery_728924EC.png"&gt;&lt;img style="border-bottom:0px;border-left:0px;display:inline;border-top:0px;border-right:0px;" title="WebPartIntroGallery" border="0" alt="WebPartIntroGallery" src="http://www.dotnetmafia.com/blogs/dotnettipoftheday/WebPartIntroGallery_thumb_2B33CEFA.png" width="514" height="23" /&gt;&lt;/a&gt; &lt;/p&gt;    &lt;p&gt;Checking the web part gallery, we see our .webpart file.&amp;#160; Let’s add it to a page and see how it looks.&amp;#160; Edit any page and use add a web part and you will see the new interface for choosing a web part.&amp;#160; It puts it in the Custom group by default.&lt;/p&gt;    &lt;p&gt;&lt;a href="http://www.dotnetmafia.com/blogs/dotnettipoftheday/WebPartIntroAddWebPart_5FD42B35.png"&gt;&lt;img style="border-bottom:0px;border-left:0px;display:inline;border-top:0px;border-right:0px;" title="WebPartIntroAddWebPart" border="0" alt="WebPartIntroAddWebPart" src="http://www.dotnetmafia.com/blogs/dotnettipoftheday/WebPartIntroAddWebPart_thumb_0A405C53.png" width="553" height="306" /&gt;&lt;/a&gt; &lt;/p&gt;    &lt;p&gt;One you hit and add finish editing, we see the web part working correctly.&lt;/p&gt;    &lt;p&gt;&lt;a href="http://www.dotnetmafia.com/blogs/dotnettipoftheday/WebPartIntroWorking_30A23F9E.png"&gt;&lt;img style="border-bottom:0px;border-left:0px;display:inline;border-top:0px;border-right:0px;" title="WebPartIntroWorking" border="0" alt="WebPartIntroWorking" src="http://www.dotnetmafia.com/blogs/dotnettipoftheday/WebPartIntroWorking_thumb_173A3C64.png" width="555" height="211" /&gt;&lt;/a&gt; &lt;/p&gt; &lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;You have to admit this is quite a bit easier than deploying a web part in SharePoint 3.&amp;#160; What if you want to debug though?&amp;#160; No problem.&amp;#160; Just set a breakpoint and choose debug from the build menu like you would any other type of project.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.dotnetmafia.com/blogs/dotnettipoftheday/WebPartIntroBreakPointHit_5DB72C6C.png"&gt;&lt;img style="border-bottom:0px;border-left:0px;display:inline;border-top:0px;border-right:0px;" title="WebPartIntroBreakPointHit" border="0" alt="WebPartIntroBreakPointHit" src="http://www.dotnetmafia.com/blogs/dotnettipoftheday/WebPartIntroBreakPointHit_thumb_48597704.png" width="563" height="76" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;As I mentioned earlier, if you are familiar with SharePoint 2010, this is nothing new to you.&amp;#160; However, my point today is for those who shied away from SharePoint in the past because the development experience was far from optimal.&amp;#160; Try it for yourself and you will see how easy it is to get up and running with your code.&amp;#160; Even with pictures this post is half the size of the WSS3 post.&amp;#160; That’s because it really is just that easy.&amp;#160; I really think Visual Studio 2010 will open the way for a new round of SharePoint developers.&amp;#160; Try it out today.&lt;/p&gt;&lt;img src="http://www.dotnetmafia.com/aggbug.aspx?PostID=2748" width="1" height="1"&gt;</description><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/SharePoint/default.aspx">SharePoint</category><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/Feature/default.aspx">Feature</category><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/WebPart/default.aspx">WebPart</category><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/Solution/default.aspx">Solution</category><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/Visual+Studio+2010/default.aspx">Visual Studio 2010</category><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/SharePoint+2010/default.aspx">SharePoint 2010</category><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/SPC09/default.aspx">SPC09</category><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/SP2010+Beta/default.aspx">SP2010 Beta</category></item><item><title>Troubleshooting Sandboxed Solutions in SharePoint 2010</title><link>http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2009/11/30/troubleshooting-sandboxed-solutions-in-sharepoint-2010.aspx</link><pubDate>Mon, 30 Nov 2009 19:08:00 GMT</pubDate><guid isPermaLink="false">ceb7fe2a-c56b-4d85-99e6-8dd548580538:1132</guid><dc:creator>CoreyRoth</dc:creator><slash:comments>16</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.dotnetmafia.com/blogs/dotnettipoftheday/rsscomments.aspx?PostID=1132</wfw:commentRss><comments>http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2009/11/30/troubleshooting-sandboxed-solutions-in-sharepoint-2010.aspx#comments</comments><description>&lt;p&gt;I have a talk coming up on Code Access Security at SharePoint Saturday Kansas City next month so I have been investigating sandboxed solutions quite a bit.&amp;#160; After all, sandboxed solutions are just another flavor of using CAS with some additional things thrown in.&amp;#160; However, after I got my SharePoint server installed and configured, I found that sandboxed solutions were not working.&amp;#160; When I configured my solution to use the sandbox and tried to deploy it, I got the following error.&lt;/p&gt;  &lt;p&gt;&lt;em&gt;Error occurred in deployment step &amp;#39;Activate Features&amp;#39;: Cannot start service SPUserCodeV4 on computer &amp;#39;servername&amp;#39;.&lt;/em&gt;&lt;/p&gt;  &lt;p&gt;I found that to be odd, so I decided to do some looking around.&amp;#160; I ended up in the Windows Services MMC snapin and found that the service called &lt;em&gt;Windows SharePoint Services UserCode Host v4&lt;/em&gt; was in fact set to disabled.&amp;#160; I changed this to automatic and started the service up.&amp;#160; I tried to deploy again, but unfortunately things still weren’t working.&amp;#160; Here is the error I got this time.&lt;/p&gt;  &lt;p&gt;&lt;em&gt;Error occurred in deployment step &amp;#39;Activate Features&amp;#39;: This feature cannot be activated at this time. The contents of the feature&amp;#39;s solution requires the Solution Sandbox service to be running.&lt;/em&gt;&lt;/p&gt;  &lt;p&gt;This one took a little bit more digging, but I ended up going to Central Administration and looking at the Services on Server page.&amp;#160; I thought what I needed would be under Service Applications, but that was not the case.&amp;#160; I took a look at Services on Server and quickly discovered that the &lt;em&gt;Microsoft SharePoint Foundation User Code Service&lt;/em&gt; had not been started.&amp;#160; I started the service and then I tried to deploy again and the errors went away and my sandboxed web part worked as expected.&amp;#160; I’m not sure why neither of these started.&amp;#160; It could be because I don’t have enough memory allocated to the virtual machine or maybe it’s always disabled by default.&amp;#160; Anyhow, be sure and check these two things before you try to work in the sandbox.&lt;/p&gt;  &lt;p&gt;UPDATE: &lt;a href="http://twitter.com/MSwannMSFT"&gt;@MSwannMSFT&lt;/a&gt; confirmed for me that this is by design.&amp;#160; It’s disabled for performance and security since it spins up three new processes.&lt;/p&gt;&lt;img src="http://www.dotnetmafia.com/aggbug.aspx?PostID=1132" width="1" height="1"&gt;</description><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/SharePoint/default.aspx">SharePoint</category><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/WebPart/default.aspx">WebPart</category><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/Visual+Studio+2010/default.aspx">Visual Studio 2010</category><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/SharePoint+2010/default.aspx">SharePoint 2010</category><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/SP2010+Beta/default.aspx">SP2010 Beta</category><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/Sandboxed+Solution/default.aspx">Sandboxed Solution</category></item><item><title>Deploying a Web Part with Code Access Security in Visual Studio 2010 (SP2010)</title><link>http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2009/11/20/deploying-a-web-part-with-code-access-security-in-visual-studio-2010-sp2010.aspx</link><pubDate>Fri, 20 Nov 2009 20:38:00 GMT</pubDate><guid isPermaLink="false">ceb7fe2a-c56b-4d85-99e6-8dd548580538:1109</guid><dc:creator>CoreyRoth</dc:creator><slash:comments>20</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.dotnetmafia.com/blogs/dotnettipoftheday/rsscomments.aspx?PostID=1109</wfw:commentRss><comments>http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2009/11/20/deploying-a-web-part-with-code-access-security-in-visual-studio-2010-sp2010.aspx#comments</comments><description>&lt;p&gt;By now, you have heard about how the SharePoint 2010 development experience has been improved.&amp;#160; We can easily deploy web parts and other code without having to manually manipulate any XML files.&amp;#160; What about under partial trust though?&amp;#160; Many of you that know me know that I have pushed using Code Access Security quite a bit through a series of blog &lt;a href="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2007/07/05/how-to-configure-code-access-security-for-a-web-part.aspx"&gt;posts&lt;/a&gt; and &lt;a href="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2008/10/08/slides-and-code-samples-from-tulsa-techfest.aspx"&gt;talks&lt;/a&gt;.&amp;#160; So it would be irresponsible of me not to talk about how we can do that in Visual Studio 2010.&amp;#160; The good news is that it is a lot easier.&lt;/p&gt;  &lt;p&gt;Let’s start by creating a new SharePoint project in Visual Studio 2010 and creating a new Web Part project item.&amp;#160; In this case we are talking about deploying a Farm Solution, not a Sandboxed Solution.&amp;#160; Note: we are going to talk about a traditional web part today, and not a Visual Web Part.&amp;#160; Visual Web Parts are simply not supposed under partial trust.&amp;#160; More on that later below.&amp;#160; My web part has some simple code which uses ASP.NET and also hits the SharePoint object model to display the title of the site in a label.&amp;#160; Here is what the code looks like.&lt;/p&gt;  &lt;div style="font-family:consolas;background:white;color:black;font-size:10pt;"&gt;   &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;protected&lt;/span&gt; &lt;span style="color:blue;"&gt;override&lt;/span&gt; &lt;span style="color:blue;"&gt;void&lt;/span&gt; CreateChildControls()&lt;/p&gt;    &lt;p style="margin:0px;"&gt;{&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; Controls.Add(&lt;span style="color:blue;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;Label&lt;/span&gt;(){Text = &lt;span style="color:#a31515;"&gt;&amp;quot;&amp;lt;div&amp;gt;My Cool Web Part!&amp;lt;/div&amp;gt;&amp;quot;&lt;/span&gt;});&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; Controls.Add(&lt;span style="color:blue;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;Label&lt;/span&gt;() { Text = &lt;span style="color:blue;"&gt;string&lt;/span&gt;.Format(&lt;span style="color:#a31515;"&gt;&amp;quot;Site Title: {0}&amp;quot;&lt;/span&gt;, &lt;span style="color:#2b91af;"&gt;SPContext&lt;/span&gt;.Current.Web.Title) });&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:blue;"&gt;base&lt;/span&gt;.CreateChildControls();&lt;/p&gt;    &lt;p style="margin:0px;"&gt;}&lt;/p&gt; &lt;/div&gt;   &lt;p&gt;When you create a new project, it deploys to the GAC by default.&amp;#160; We start by changing this on the project properties.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.dotnetmafia.com/blogs/dotnettipoftheday/CASWebApplication_27C5F577.png"&gt;&lt;img style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" title="CASWebApplication" border="0" alt="CASWebApplication" src="http://www.dotnetmafia.com/blogs/dotnettipoftheday/CASWebApplication_thumb_0DF1BF48.png" width="306" height="161" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;This effectively changes the &lt;em&gt;DeploymentTarget &lt;/em&gt;attribute on Assembly element in the Manifest.xml.&amp;#160; At this point, you may be asking.&amp;#160; “Sweet, is that it?&amp;#160; Does it take care of the CAS policy for me?”&amp;#160; The answer to that of course is “No.”&amp;#160; However, it is quite easy to add it.&amp;#160; Let’s see what happens if we try to deploy it as is.&amp;#160; I’ll just hit F5 to start debugging.&amp;#160; I then add my web part to any existing page, and I immediately get hit with the following in Visual Studio.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.dotnetmafia.com/blogs/dotnettipoftheday/CASSecurityExceptionYellowScreen_3B72DF0B.png"&gt;&lt;img style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" title="CASSecurityExceptionYellowScreen" border="0" alt="CASSecurityExceptionYellowScreen" src="http://www.dotnetmafia.com/blogs/dotnettipoftheday/CASSecurityExceptionYellowScreen_thumb_5F2C06A5.png" width="600" height="153" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;&lt;em&gt;System.Security.SecurityException: Request for the permission of type &amp;#39;Microsoft.SharePoint.Security.SharePointPermission, Microsoft.SharePoint.Security, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c&amp;#39; failed.&lt;/em&gt;&lt;/p&gt;  &lt;p&gt;Luckily we know how to fix this.&amp;#160; Hopefully, this will also help new developers when they get this error in the future and aren’t sure what to do.&amp;#160; We need to grant permissions to this assembly to use the object model as well as a few other things.&amp;#160; We’ll start by using a standard set of IPermission elements that I have used in past &lt;a href="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2007/07/05/how-to-configure-code-access-security-for-a-web-part.aspx"&gt;posts&lt;/a&gt;.&amp;#160; This gives me basic ASP.NET, SharePoint object model, and Security permissions.&lt;/p&gt;  &lt;div style="font-family:consolas;background:white;color:black;font-size:10pt;"&gt;   &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;CodeAccessSecurity&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;#160; &amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;PolicyItem&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;PermissionSet&lt;/span&gt;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;class&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;NamedPermissionSet&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;version&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;1&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;Description&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;Permission set for VisualWebPartProject1.&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;IPermission&lt;/span&gt;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;class&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;AspNetHostingPermission&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;version&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;1&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;Level&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;Minimal&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt; /&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;IPermission&lt;/span&gt;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;class&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;SecurityPermission&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;version&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;1&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;Flags&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;Execution,ControlPrincipal,ControlAppDomain,ControlDomainPolicy,ControlEvidence,ControlThread&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt; /&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;IPermission&lt;/span&gt;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;class&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;Microsoft.SharePoint.Security.SharePointPermission, Microsoft.SharePoint.Security, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c&lt;/span&gt;&amp;quot;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;span style="color:red;"&gt;version&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;1&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;ObjectModel&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;True&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;&amp;#160; /&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;IPermission&lt;/span&gt;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;class&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;System.Security.Permissions.EnvironmentPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;version&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;1&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;Read&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;UserName&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt; /&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;IPermission&lt;/span&gt;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;class&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;version&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;1&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;Read&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;$AppDir$&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;Write&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;$AppDir$&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;Append&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;$AppDir$&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;PathDiscovery&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;$AppDir$&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt; /&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;PermissionSet&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Assemblies&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Assembly&lt;/span&gt;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;Name&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;VisualWebPartProject1&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;&amp;#160; /&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Assemblies&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;#160; &amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;PolicyItem&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;CodeAccessSecurity&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt; &lt;/div&gt;   &lt;p&gt;You can use this in your code almost exactly but two small changes are required.&amp;#160; First, you need to change your assembly name to whatever you have called yours.&amp;#160; Secondly, if you look at that SharePointPermission, you’ll notice it says version 12.0.0.0.&amp;#160; We need to change this to 14.0.0.0 since we are working with SharePoint 2010 now.&amp;#160; Adding this to your package is quite easy.&amp;#160; In the Solution Explorer, locate Package and then Package.package and open it.&amp;#160; This will bring open the package designer.&amp;#160; Click on the &lt;em&gt;Manifest&lt;/em&gt; tab at the bottom and then expand &lt;em&gt;Edit Options&lt;/em&gt;.&amp;#160; The way this works is that you can paste any &lt;em&gt;additional&lt;/em&gt; elements here and it will merge your items with the ones it automatically generates.&amp;#160; Here is what I would paste in.&lt;/p&gt;  &lt;div style="font-family:consolas;background:white;color:black;font-size:10pt;"&gt;   &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;lt;?&lt;/span&gt;&lt;span style="color:#a31515;"&gt;xml&lt;/span&gt;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;version&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;1.0&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;encoding&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;utf-8&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;?&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Solution&lt;/span&gt;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;xmlns&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;http://schemas.microsoft.com/sharepoint/&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;#160; &amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;CodeAccessSecurity&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;PolicyItem&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;PermissionSet&lt;/span&gt;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;class&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;NamedPermissionSet&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;version&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;1&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;Description&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;Permission set for VisualWebPartProject1.&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;IPermission&lt;/span&gt;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;class&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;AspNetHostingPermission&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;version&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;1&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;Level&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;Minimal&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt; /&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;IPermission&lt;/span&gt;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;class&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;SecurityPermission&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;version&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;1&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;Flags&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;Execution,ControlPrincipal,ControlAppDomain,ControlDomainPolicy,ControlEvidence,ControlThread&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt; /&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;IPermission&lt;/span&gt;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;class&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;Microsoft.SharePoint.Security.SharePointPermission, Microsoft.SharePoint.Security, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c&lt;/span&gt;&amp;quot;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;span style="color:red;"&gt;version&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;1&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;ObjectModel&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;True&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;&amp;#160; /&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;IPermission&lt;/span&gt;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;class&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;System.Security.Permissions.EnvironmentPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;version&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;1&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;Read&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;UserName&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt; /&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;IPermission&lt;/span&gt;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;class&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;version&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;1&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;Read&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;$AppDir$;C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\CONTROLTEMPLATES\VisualWebPartProject1&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;Write&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;$AppDir$&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;Append&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;$AppDir$&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;PathDiscovery&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;$AppDir$&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt; /&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;PermissionSet&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Assemblies&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Assembly&lt;/span&gt;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;Name&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;VisualWebPartProject1&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;&amp;#160; /&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Assemblies&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;PolicyItem&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;#160; &amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;CodeAccessSecurity&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Solution&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt; &lt;/div&gt;   &lt;p&gt;Here is what it would look like on the screen.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.dotnetmafia.com/blogs/dotnettipoftheday/CASPackageEditor_2CC83326.png"&gt;&lt;img style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" title="CASPackageEditor" border="0" alt="CASPackageEditor" src="http://www.dotnetmafia.com/blogs/dotnettipoftheday/CASPackageEditor_thumb_5DE76DC6.png" width="606" height="526" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;If everything is correct, you will see the merged result up top.&amp;#160; If there is an error in your XML, you will also see it there.&amp;#160; Now let’s deploy the solution and see if we can add the web part to an existing page.&amp;#160; &lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.dotnetmafia.com/blogs/dotnettipoftheday/CASAPTCAError_0AFC5A95.png"&gt;&lt;img style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" title="CASAPTCAError" border="0" alt="CASAPTCAError" src="http://www.dotnetmafia.com/blogs/dotnettipoftheday/CASAPTCAError_thumb_4AC6411A.png" width="325" height="131" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Unfortunately, this is the error we get and it actually gives us good information.&amp;#160; We simply forgot to add the APTCA attribute (or AllowPartiallyTrustedCallers).&amp;#160; Just open your AssmeblyInfo.cs file and add the following line.&lt;/p&gt;  &lt;div style="font-family:consolas;background:white;color:black;font-size:10pt;"&gt;   &lt;p style="margin:0px;"&gt;[&lt;span style="color:blue;"&gt;assembly&lt;/span&gt;: &lt;span style="color:#2b91af;"&gt;AllowPartiallyTrustedCallers&lt;/span&gt;()]&lt;/p&gt; &lt;/div&gt;   &lt;p&gt;Redeploy your solution and try to add your web part again.&amp;#160; If all goes well, you will have a lovely web part on the screen that looks like this.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.dotnetmafia.com/blogs/dotnettipoftheday/CASWorkingWebPart_3C87C82A.png"&gt;&lt;img style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" title="CASWorkingWebPart" border="0" alt="CASWorkingWebPart" src="http://www.dotnetmafia.com/blogs/dotnettipoftheday/CASWorkingWebPart_thumb_38114763.png" width="491" height="238" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;With the above set of CAS policies, you can probably get most of the code you want to do to work.&amp;#160; I mentioned Visual Web Parts above.&amp;#160; Here is the issue I am currently seeing.&amp;#160; If you remember my post on the &lt;a href="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2009/10/20/introducing-the-visual-web-part-in-sharepoint-2010.aspx"&gt;Visual Web Part&lt;/a&gt;, you will know that this is just a web part with a Page.LoadControl() method calling a User Control (.ascx).&amp;#160; Page.LoadControl requires a ton of permissions and I haven’t been able to figure them out.&amp;#160; This means, it simply will not work.&amp;#160; I posted something to the &lt;a href="http://social.msdn.microsoft.com:80/Forums/en-US/sharepoint2010programming/thread/f244f7f6-b0f6-4e0d-9f5f-c7d423cdda60"&gt;forums&lt;/a&gt; about it.&amp;#160; Paul Andrew was nice enough to respond to my post and state that Page.LoadControl simply will not function under partial trust.&amp;#160; It has a check in it to verify that it is not running under partial trust.&amp;#160; He also goes on to explain this is why you can’t use Visual Web Parts in sandboxed solutions.&lt;/p&gt;  &lt;p&gt;This may seem like a lot of steps, but really I just posted a lot of pictures.&amp;#160; Trust me it’s a lot fewer steps than it was before in MOSS 2007.&amp;#160; Just look at my old &lt;a href="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2007/07/05/how-to-configure-code-access-security-for-a-web-part.aspx"&gt;post&lt;/a&gt; if you don’t believe me.&amp;#160; Now, you might ask why would I do this instead of a Sandboxed solution?&amp;#160; Sandboxed solutions are severely limited on what they can do with the SharePoint object model.&amp;#160; By default, the CAS policy that defines them can’t even connect to a database.&amp;#160; I can specify at a per assembly level here what each one can do.&amp;#160; That is a big advantage.&lt;/p&gt;&lt;img src="http://www.dotnetmafia.com/aggbug.aspx?PostID=1109" width="1" height="1"&gt;</description><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/SharePoint/default.aspx">SharePoint</category><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/Code+Access+Security/default.aspx">Code Access Security</category><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/WebPart/default.aspx">WebPart</category><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/Visual+Studio+2010/default.aspx">Visual Studio 2010</category><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/SharePoint+2010/default.aspx">SharePoint 2010</category><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/SP2010+Beta/default.aspx">SP2010 Beta</category></item><item><title>Introducing the Visual Web Part in SharePoint 2010</title><link>http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2009/10/20/introducing-the-visual-web-part-in-sharepoint-2010.aspx</link><pubDate>Tue, 20 Oct 2009 21:38:19 GMT</pubDate><guid isPermaLink="false">ceb7fe2a-c56b-4d85-99e6-8dd548580538:1011</guid><dc:creator>CoreyRoth</dc:creator><slash:comments>5</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.dotnetmafia.com/blogs/dotnettipoftheday/rsscomments.aspx?PostID=1011</wfw:commentRss><comments>http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2009/10/20/introducing-the-visual-web-part-in-sharepoint-2010.aspx#comments</comments><description>&lt;p&gt;You might have seen that there is a new designer for working with web parts in Visual Studio 2010.&amp;#160; This is actually, not quite the case, so I thought I would share with you how it actually works.&amp;#160; When you use the Visual Web Part SPI (SharePoint Project Item), it will create a number of files for you: a .cs file, a .webpart file, an elements.xml file, and a .ascx file.&amp;#160; That’s right, it creates an ASP.NET user control.&amp;#160; Now, the Visual Studio interface does a nice job of grouping all of the files together.&amp;#160; When you open the designer on the web part, you in fact just open the designer for the user control.&amp;#160; &lt;/p&gt;  &lt;p&gt;So now you might be thinking, how does this work?&amp;#160; Well no SharePoint can’t host user controls directly still. In fact all it does is create a simple web part with a Page.LoadControl() method pointing at our user control.&amp;#160; This in fact is the same method we’ve been using for years to get user controls into SharePoint.&amp;#160; I don’t really see this as an issue though, since Visual Studio does a great job making it painless to deploy these now and use them inside SharePoint.&lt;/p&gt;&lt;img src="http://www.dotnetmafia.com/aggbug.aspx?PostID=1011" width="1" height="1"&gt;</description><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/SharePoint/default.aspx">SharePoint</category><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/WebPart/default.aspx">WebPart</category><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/Visual+Studio+2010/default.aspx">Visual Studio 2010</category><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/SharePoint+2010/default.aspx">SharePoint 2010</category><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/SPC09/default.aspx">SPC09</category><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/SP2010+Beta/default.aspx">SP2010 Beta</category></item></channel></rss>