<?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] : Deployment, Solution, Feature</title><link>http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/Deployment/Solution/Feature/default.aspx</link><description>Tags: Deployment, Solution, Feature</description><dc:language>en</dc:language><generator>CommunityServer 2007.1 (Build: 20917.1142)</generator><item><title>Intro to SharePoint Development: How to Build and Deploy a Web Part</title><link>http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2008/10/22/intro-to-sharepoint-development-how-to-build-and-deploy-a-web-part.aspx</link><pubDate>Wed, 22 Oct 2008 12:50:00 GMT</pubDate><guid isPermaLink="false">ceb7fe2a-c56b-4d85-99e6-8dd548580538:751</guid><dc:creator>CoreyRoth</dc:creator><slash:comments>31</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.dotnetmafia.com/blogs/dotnettipoftheday/rsscomments.aspx?PostID=751</wfw:commentRss><comments>http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2008/10/22/intro-to-sharepoint-development-how-to-build-and-deploy-a-web-part.aspx#comments</comments><description>&lt;p&gt;UPDATE: &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 Web Parts in SharePoint 2010&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;I&amp;#39;ve recently helped out a number of developers new to SharePoint and I found that I have been often asked the same types of questions.&amp;nbsp; Most of those involve getting started and deployment, so today, I am beginning my series on getting started with SharePoint.&amp;nbsp; Most new developers find starting out pretty overwhelming, but once you get used to it, it does all make sense.&amp;nbsp; Hopefully this post will help the community and keep new SharePoint developers from getting scared off.&amp;nbsp; There have been a lot of posts on this topic I admit.&amp;nbsp; Since there are so many ways to do things, I wanted to write this post as a reference to new developers so they can see how I usually do things.&amp;nbsp; What I find is that most developers have no trouble getting a web part built, but when it comes time to deploy it, they are lost.&amp;nbsp; There are multiple ways to do this and not all of them are necessarily the right way.&lt;/p&gt; &lt;h4&gt;Environment&lt;/h4&gt; &lt;p&gt;Let&amp;#39;s start by talking about your development environment.&amp;nbsp; In an ideal situation, you probably have your own virtual machine with Windows Server 2008 (or 2003), MOSS 2007, and Visual Studio 2008 installed.&amp;nbsp; However, maybe you don&amp;#39;t have your own dedicated machine and you are going to be developing on a Windows XP machine, but deploying to a remote SharePoint server.&amp;nbsp; This is fine, but you are going to have to do some things a little differently.&amp;nbsp; First, you won&amp;#39;t be able to install the &lt;a href="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2008/06/04/wss-3-0-tools-visual-studio-extensions-1-2-running-under-windows-vista.aspx"&gt;Visual Studio Extensions for SharePoint&lt;/a&gt;.&amp;nbsp; You can live without this though because most people I have ran into say they don&amp;#39;t use them.&amp;nbsp; Secondly, when it comes to deployment (which we&amp;#39;ll talk about down below), you are going to have to copy your source files (either manually or via solution package) to the server.&amp;nbsp; You are also going to have to &lt;a href="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2008/03/05/how-to-remote-debugging-a-web-application.aspx"&gt;remote debug&lt;/a&gt; but fret not my post on it makes it easy.&lt;/p&gt; &lt;p&gt;If you are developing on a desktop, another thing you will need to do is copy the SharePoint assemblies to your computer.&amp;nbsp; We can easily get these from a deployed SharePoint server.&amp;nbsp; However, this is a great time to take an aside and talk about some of the SharePoint directory structure.&lt;/p&gt; &lt;p&gt;&lt;em&gt;C:\Program Files\Common Files\microsoft shared\Web Server Extensions\12&lt;/em&gt;&lt;/p&gt; &lt;p&gt;All SharePoint developers have that file path permanently burned into their memory.&amp;nbsp; It is often referred to as the 12 hive.&amp;nbsp; A lot of things happen within this folder.&amp;nbsp; Subfolders here contain the SharePoint binaries, Master Pages, Application Pages, User Controls, Configuration Files, and Features.&amp;nbsp;&amp;nbsp; Although SharePoint will let you customize any file in here, in general you don&amp;#39;t want to make changes to any of these builtin files as it puts you in an unsupported scenario.&amp;nbsp; If you want to customize a master page or a style, it is typically best that you make a copy of what you want to customize and go from there.&amp;nbsp; Here is a quick list of some of the key folders and what they are used for.&lt;/p&gt; &lt;table cellspacing="0" cellpadding="2"&gt;  &lt;tr&gt; &lt;td&gt;&lt;strong&gt;Folder&lt;/strong&gt;&lt;/td&gt; &lt;td&gt;&lt;strong&gt;Description&lt;/strong&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;CONFIG&lt;/td&gt; &lt;td&gt;Contains &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;partial trust&lt;/a&gt; configuration files&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;ISAPI&lt;/td&gt; &lt;td&gt;Binaries and SharePoint Web Services&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;LOGS&lt;/td&gt; &lt;td&gt;Error Logs (look here first when you get a strange error)&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;TEMPLATE\CONTROLTEMPLATES&lt;/td&gt; &lt;td&gt;User Controls&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;TEMPLATE\FEATURES&lt;/td&gt; &lt;td&gt;SharePoint Features (turns functionality on and off)&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;TEMPLATE\IMAGES&lt;/td&gt; &lt;td&gt;MainImages Folder&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;TEMPLATE\LAYOUTS&lt;/td&gt; &lt;td&gt;Pages and Styles&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;TEMPLATE\SiteTemplates&lt;/td&gt; &lt;td&gt;Definitions avaiable for deploying new sites&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;TEMPLATE\THEMES&lt;/td&gt; &lt;td&gt;Used to create custom themes in SharePoint&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;TEMPLATE\XML&lt;/td&gt; &lt;td&gt;Contains XSDs for any XML used with SharePoint&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt; &lt;p&gt;Enough on that tangent, back to the assemblies that we need to copy.&amp;nbsp; Go to the above path and then go into the ISAPI folder.&amp;nbsp; Copy all of the DLLs from this folder onto your desktop machine in the corresponding folder name.&amp;nbsp; If you don&amp;#39;t have that folder, create it.&amp;nbsp; You may also copy them to the Global Assembly Cache as well.&amp;nbsp; Once you are this point, you are ready to being building a web part.&lt;/p&gt; &lt;h4&gt;Coding the Web Part&lt;/h4&gt; &lt;p&gt;Start by creating a new class library project in Visual Studio.&amp;nbsp; There are packages and tools out there to automate some of these steps, but its best that you learn how to do it first by hand, so you know how to troubleshoot it should something go wrong.&amp;nbsp; Next, you will want to add (at a minimum) a reference to Microsoft.SharePoint.dll.&amp;nbsp; You can either grab it out of the GAC (will be listed under Windows SharePoint Services) or use the copy that you put in your ISAPI folder.&amp;nbsp; After you add it, make sure &lt;em&gt;Copy Local&lt;/em&gt; is set to false on your reference.&amp;nbsp; You will also want to add System.Web since more than likely your web part will use an ASP.NET control in it.&amp;nbsp; You are now ready to create your web part.&amp;nbsp; To do this, create a new class and add a using statement for &lt;em&gt;Microsoft.SharePoint&lt;/em&gt;.&amp;nbsp; In the past, you would derive your class from &lt;em&gt;Microsoft.SharePoint.WebPart&lt;/em&gt; (and you still can), but now the more accepted way of doing things is to derive from the new &lt;em&gt;System.Web.UI.WebParts.WebPart&lt;/em&gt; class.&amp;nbsp; The latter comes from ASP.NET 2.0 and can actually be deployed outside of SharePoint.&amp;nbsp; Here is what our class is going to look like.&lt;/p&gt; &lt;div style="font-size:10pt;background:white;color:black;font-family:courier new;"&gt; &lt;p style="margin:0px;"&gt;&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;TestWebPart&lt;/span&gt; : System.Web.UI.WebControls.WebParts.&lt;span style="color:#2b91af;"&gt;WebPart&lt;/span&gt;&lt;/p&gt; &lt;p style="margin:0px;"&gt;{&lt;/p&gt; &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &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;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/p&gt; &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:blue;"&gt;base&lt;/span&gt;.CreateChildControls();&lt;/p&gt; &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 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;My Test Web Part (Hello World)!&amp;quot;&lt;/span&gt;});&lt;/p&gt; &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/p&gt; &lt;p style="margin:0px;"&gt;}&lt;/p&gt;&lt;/div&gt; &lt;p&gt;The content of the class is simple.&amp;nbsp; We use the overridden &lt;em&gt;CreateChildControls&lt;/em&gt; method to add ASP.NET controls to the page to do the rendering.&amp;nbsp; I simply call Control.Add and add a Label control with the text above.&amp;nbsp; Compile it and this web part is good to go, but there is the small matter of deploying it.&amp;nbsp; Compiling it yield you a DLL that has be deployed to SharePoint somehow.&amp;nbsp; SharePoint also needs to know where the web part is and how to reference it.&amp;nbsp; This is where the .webpart file comes in.&lt;/p&gt; &lt;h4&gt;Describing the WebPart&lt;/h4&gt; &lt;p&gt;The .webpart file is an XML file that tells SharePoint what to call your DLL and what assembly it is located in.&amp;nbsp; The easiest way to get started creating this file is to copy another one in SharePoint.&amp;nbsp; You can find plenty of examples by going to your web part gallery (Site Root -&amp;gt; Site Settings -&amp;gt; Web Parts).&amp;nbsp; this file simply describes the class and assembly of your web part as well as some default properties (i.e.: it sets a title and description).&amp;nbsp; You can also add your own properties by specifying a series of attributes on a property in your class.&lt;/p&gt; &lt;div style="font-size:10pt;background:white;color:black;font-family:courier new;"&gt; &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;webParts&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;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;webPart&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/WebPart/v3&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;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;metaData&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;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;type&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;MyWebPart.TestWebPart, MyWebPart, Version=1.0.0.0, Culture=neutral&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;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;importErrorMessage&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;Cannot import this Web Part.&lt;span style="color:blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;importErrorMessage&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;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;metaData&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;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;data&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;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;properties&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;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;property&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;Title&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;type&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;string&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;My Web Part&lt;span style="color:blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;property&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;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;property&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;Description&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;type&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;string&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;A test web part.&lt;span style="color:blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;property&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;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;properties&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;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;data&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;nbsp; &amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;webPart&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;/div&gt; &lt;p&gt;Note: There is also a &lt;a href="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2008/08/21/the-difference-between-dwp-and-webpart.aspx"&gt;.dwp&lt;/a&gt; file, which comes from version 2, that can describe your webpart as well.&amp;nbsp; It still works but it is consider deprecated.&lt;/p&gt; &lt;h4&gt;Ghetto Deploying&lt;/h4&gt; &lt;p&gt;So far, we have built a web part and created a .webpart file so now it is time to deploy it.&amp;nbsp; We&amp;#39;ll start by doing it the &lt;em&gt;wrong&lt;/em&gt; way.&amp;nbsp; The first thing to know is that you can&amp;#39;t just copy your DLL into the bin folder of your web application unless you change to full trust (not recommended) or specify &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;Code Access Security&lt;/a&gt;.&amp;nbsp; Specifying CAS when first starting out will make even the most seasoned developers run for the hills.&amp;nbsp; So we are going to start by deploying to the GAC.&amp;nbsp; In almost all situations, I recommend against this, but for the sake of getting you started, it is ok.&amp;nbsp; You can then follow the Code Access Security post later on how to set up everything properly.&lt;/p&gt; &lt;p&gt;Start by copying your compiled DLL into the Global Assembly Cache of your SharePoint server.&amp;nbsp; Keep in mind anytime you update this DLL, you will need to either reset IIS or recycle the application pool (otherwise the old version stays in memory).&amp;nbsp; The next thing you need to do is upload the .webpart file to the web part gallery of your site collection (again Site Root -&amp;gt; Site Settings -&amp;gt; Web Parts).&amp;nbsp; At this point, SharePoint will be able to recognize your web part and it can be added to a page.&amp;nbsp; If you click on the name of the web part in the gallery (in this case MyWebPart.webpart), it will display a preview of what it will look like on a page.&amp;nbsp; If everything is working correctly, you will see your web part, otherwise you will get an error.&amp;nbsp; At this point, you will have the following error.&lt;/p&gt; &lt;p&gt;&lt;span class="Apple-style-span" style="word-spacing:0px;font:13px verdana;text-transform:none;text-indent:0px;white-space:normal;letter-spacing:normal;border-collapse:separate;orphans:2;widows:2;-webkit-border-horizontal-spacing:0px;-webkit-border-vertical-spacing:0px;-webkit-text-decorations-in-effect:none;-webkit-text-size-adjust:auto;-webkit-text-stroke-width:0;"&gt;&lt;em&gt;A web part on this web part page cannot be displayed or imported because it is not registered on this site as safe.&lt;/em&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;This is because there is one more step to do.&amp;nbsp; Every web part or user control in SharePoint must be registered as safe to execute in the web.config.&amp;nbsp; To do this, find the &lt;em&gt;SafeControls&lt;/em&gt; element near the top and add the following line (changing it with your fully qualified assembly path).&lt;/p&gt; &lt;div style="font-size:10pt;background:white;color:black;font-family:courier new;"&gt; &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;SafeControls&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;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;SafeControl&lt;/span&gt;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;Assembly&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;MyWebPart, Version=1.0.0.0, Culture=neutral&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;Namespace&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;MyWebPart&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;TypeName&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;*&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;Safe&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;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;SafeControls&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;/div&gt; &lt;p&gt;Now when you go back to the web part gallery, it should give you a preview of your web part.&amp;nbsp; If it doesn&amp;#39;t check your assembly paths and make sure the file is deployed.&amp;nbsp; If you still have issues, check out this post on &lt;a href="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2008/10/06/troubleshooting-cannot-import-web-part-error.aspx"&gt;troubleshooting a web part&lt;/a&gt;.&amp;nbsp; Assuming you were able to get the web part to preview, you can also go add it to a page by going to any page, clicking Edit Page and then Add Web Part.&amp;nbsp; Scroll through the list until you find your web part and select it.&amp;nbsp; You should then see your web part on the page.&lt;/p&gt; &lt;h4&gt;Features&lt;/h4&gt; &lt;p&gt;So we talked about deploying a web part the wrong way.&amp;nbsp; Ok, it&amp;#39;s not necessarily wrong, but it really adds a lot of extra work&amp;nbsp; This can be automated quite a bit by using features and solution packages.&amp;nbsp; Creating a feature, allows you to turn on and off customizations to SharePoint at the click of a button.&amp;nbsp; They can be used to deploy web parts, site definitions, workflows, document libraries, and plenty of other things.&amp;nbsp; In this case, we are building a feature to automate the deployment of our .webpart file.&amp;nbsp; You can also specify a class (Feature Receiver) that is executed when the feature is installed, activated, deactivated, or uninstalled.&amp;nbsp; A feature typically consists of two XML files.&amp;nbsp; The first file Feature.xml (must be named that), describes the feature and where its feature receiver is (if any).&amp;nbsp; &lt;/p&gt; &lt;div style="font-size:10pt;background:white;color:black;font-family:courier new;"&gt; &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Feature&lt;/span&gt;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;/p&gt; &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &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; &lt;/span&gt;&lt;/p&gt; &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color:red;"&gt;Id&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;{BDD425C3-CA50-4aee-9170-73954044D764}&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;/p&gt; &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color:red;"&gt;Scope&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;Site&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;/p&gt; &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color:red;"&gt;Hidden&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;False&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;/p&gt; &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color:red;"&gt;Title&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;My Web Part&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;/p&gt; &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &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;My Test Web Part&lt;/span&gt;&amp;quot;&lt;/p&gt; &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;gt;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;ElementManifests&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;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;ElementManifest&lt;/span&gt;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;Location&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;Elements.xml&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;nbsp; &amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;ElementManifests&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;Feature&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;/div&gt; &lt;p&gt;The &lt;em&gt;Id&lt;/em&gt; element contains a GUID.&amp;nbsp; Every feature needs a different one.&amp;nbsp; The &lt;em&gt;Scope &lt;/em&gt;attribute specifies where to deploy the feature.&amp;nbsp; Possible values are &lt;em&gt;Site, Web, WebApplication, &lt;/em&gt;and &lt;em&gt;Farm&lt;/em&gt;.&amp;nbsp; I would go into the difference in scopes, because this post is already getting long enough.&amp;nbsp; You will most likely use Site or Web for most things you do (&lt;a href="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2008/08/21/sharepoint-to-api-translation-guide.aspx"&gt;note on terms in API&lt;/a&gt;).&amp;nbsp; The &lt;em&gt;ElementManifest &lt;/em&gt;element makes calls to additional XML files.&amp;nbsp; Typically the other file is called Elements.xml (although it can be called anything).&lt;/p&gt; &lt;p&gt;The Elements.xml file can be used to deploy files, create document libraries, and many other functions.&amp;nbsp; I won&amp;#39;t go into the whole detail of this file (it&amp;#39;s in the SDK), but basically we are specifying that the &lt;em&gt;MyWebPart.webpart&lt;/em&gt; file should be copied into the web part gallery.&amp;nbsp; I will tell you what a few things are though.&amp;nbsp; In this case the Module element says that we are going to deploy something into a list that is located at &lt;em&gt;_catalogs/wp &lt;/em&gt;(this is the URL of the web part gallery).&amp;nbsp; How did I figure this out?&amp;nbsp; I looked at another example.&amp;nbsp; The File element deploys our MyWebPart.webpart file into the web part gallery.&amp;nbsp; I wont go into why you set the Type to &lt;em&gt;GhostableInLibrary&lt;/em&gt; right now.&amp;nbsp; Just know this is the value you will pretty much always use.&lt;/p&gt; &lt;div style="font-size:10pt;background:white;color:black;font-family:courier new;"&gt; &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Elements&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;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Module&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;WebPartPopulation&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;List&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;113&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;Url&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;_catalogs/wp&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;RootWebOnly&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;gt;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;File&lt;/span&gt;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;Url&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;MyWebPart.webpart&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;Type&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;GhostableInLibrary&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;nbsp; &amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Module&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;Elements&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;/div&gt; &lt;p&gt;When the feature is activated, it will put the file in the web part gallery.&amp;nbsp; However, it won&amp;#39;t &lt;a href="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2008/03/04/reminder-delete-web-parts-from-gallery-when-changing-version-numbers.aspx"&gt;remove the item&lt;/a&gt; from the web part gallery on deactivation.&amp;nbsp; It&amp;#39;s pretty easy to do with code and I still plan to write a post on it.&amp;nbsp; For now, if you want the .webpart file gone you will have to delete it manually.&amp;nbsp; During the development cycle though, the only time it really is necessary to remove a .webpart file is if you have changed the namespace, class name, or public key token.&amp;nbsp; Here is what an elements file typically looks like for deploying a web part.&lt;/p&gt; &lt;p&gt;So where do all these files go?&amp;nbsp; Let&amp;#39;s talk about where you put them in your Visual Studio project first.&amp;nbsp; Typically, what you will do is create a folder structure in your project that matches the 12 hive.&amp;nbsp; So in this case, we will create a TEMPLATE\FEATURES folder.&amp;nbsp; We will then create a folder for our web part.&amp;nbsp; I am just calling it MyWebPart for now.&amp;nbsp; Here is what your solution will look like.&amp;nbsp; This folder is where you will put Feature.xml, Elements.xml, and MyWebPart.webpart.&lt;/p&gt; &lt;p&gt;&lt;a href="http://www.dotnetmafia.com/blogs/dotnettipoftheday/WindowsLiveWriter/BacktoBasicsHowtoBuildandDeployaWebPart_E55A/image_2.png"&gt;&lt;img style="border-top-width:0px;border-left-width:0px;border-bottom-width:0px;border-right-width:0px;" height="244" alt="image" src="http://www.dotnetmafia.com/blogs/dotnettipoftheday/WindowsLiveWriter/BacktoBasicsHowtoBuildandDeployaWebPart_E55A/image_thumb.png" width="238" border="0" /&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;To deploy the feature, copy it to the TEMPLATE\FEATURES folder in your 12 hive.&amp;nbsp; You then need to use stsadm command to install it.&amp;nbsp; The stsadm executable is located in the bin folder of the 12 hive.&amp;nbsp; You tend to use it a lot, so you might want to put it in your path environment variable.&amp;nbsp; Once you have located it, issue the following command.&lt;/p&gt; &lt;p&gt;&lt;em&gt;stsadm -o installfeature -name MyWebPart&lt;/em&gt;&lt;/p&gt; &lt;p&gt;This makes the feature available to be activated.&amp;nbsp;&amp;nbsp; To activate it, go to Site Collection Features (Site Root -&amp;gt; Site Settings -&amp;gt; Site Collection Features).&amp;nbsp; Find the feature in the list and click the Activate button.&amp;nbsp; This deploys the web part to the gallery and it can be added to pages as before.&amp;nbsp; If you ever want to remove the feature, use the &lt;em&gt;uninstallfeature&lt;/em&gt; operation.&amp;nbsp; You will want to deactivate the feature first, otherwise you will have to use the -force parameter when using stsadm.&lt;/p&gt; &lt;h4&gt;Deploying Via Solution Package&lt;/h4&gt; &lt;p&gt;Features are nice, but we can take this one step further.&amp;nbsp; A solution package (.wsp file) allows you to package your entire solution into one .wsp file for deployment.&amp;nbsp; A .wsp file is simply a cab file with a manifest.xml file that tells SharePoint how to install the contents.&amp;nbsp; It will even deploy and install your feature for you, allowing you to skip the installation steps above.&amp;nbsp; Two files are required to build the .wsp file: cab.ddf and manifest.xml.&amp;nbsp; These files typically go into a folder called Solution in your Visual Studio project.&amp;nbsp; Cab.ddf tells the utility, makecab.exe, how to construct the .wsp file.&amp;nbsp;&amp;nbsp; Below is an example DDF file.&amp;nbsp; You will need to set the &lt;em&gt;CabinetNameTemplate&lt;/em&gt; to the filename you want for your wsp file.&amp;nbsp; You then specify a source and destination for each file you want copied.&amp;nbsp; In the example below, note that I am copying the DLL, Elements.xml, Feature.xml, and MyWebPart.webpart file.&amp;nbsp; &lt;/p&gt; &lt;div style="font-size:10pt;background:white;color:black;font-family:courier new;"&gt; &lt;p style="margin:0px;"&gt;; ** MyWebPart.wsp **&lt;/p&gt; &lt;p style="margin:0px;"&gt;.OPTION EXPLICIT&amp;nbsp;&amp;nbsp;&amp;nbsp; ; Generate errors &lt;/p&gt; &lt;p style="margin:0px;"&gt;.Set CabinetNameTemplate=MyWebPart.wsp&lt;/p&gt; &lt;p style="margin:0px;"&gt;.set DiskDirectoryTemplate=CDROM ; All cabinets go in a single directory&lt;/p&gt; &lt;p style="margin:0px;"&gt;.Set CompressionType=MSZIP;** All files are compressed in cabinet files&lt;/p&gt; &lt;p style="margin:0px;"&gt;.Set UniqueFiles=&amp;quot;ON&amp;quot;&lt;/p&gt; &lt;p style="margin:0px;"&gt;.Set Cabinet=on&lt;/p&gt; &lt;p style="margin:0px;"&gt;.Set DiskDirectory1=Package&lt;/p&gt; &lt;p style="margin:0px;"&gt;&amp;nbsp;&lt;/p&gt; &lt;p style="margin:0px;"&gt;Solution\manifest.xml manifest.xml&lt;/p&gt; &lt;p style="margin:0px;"&gt;&amp;nbsp;&lt;/p&gt; &lt;p style="margin:0px;"&gt;; binary&lt;/p&gt; &lt;p style="margin:0px;"&gt;bin\debug\MyWebPart.dll MyWebPart.dll&lt;/p&gt; &lt;p style="margin:0px;"&gt;&amp;nbsp;&lt;/p&gt; &lt;p style="margin:0px;"&gt;; feature files&lt;/p&gt; &lt;p style="margin:0px;"&gt;TEMPLATE\FEATURES\MyWebPart\Elements.xml MyWebPart\Elements.xml&lt;/p&gt; &lt;p style="margin:0px;"&gt;TEMPLATE\FEATURES\MyWebPart\Feature.xml MyWebPart\Feature.xml&lt;/p&gt; &lt;p style="margin:0px;"&gt;&amp;nbsp;&lt;/p&gt; &lt;p style="margin:0px;"&gt;; web part files&lt;/p&gt; &lt;p style="margin:0px;"&gt;TEMPLATE\FEATURES\MyWebPart\MyWebPart.webpart FEATURES\MyWebPart\MyWebPart.webpart&lt;/p&gt;&lt;/div&gt; &lt;p&gt;I won&amp;#39;t go into manifest.xml again because I have already covered it once in this &lt;a href="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2008/09/04/more-on-manfiest-xml.aspx"&gt;post&lt;/a&gt;.&amp;nbsp; It&amp;#39;s this file that tells SharePoint how to deploy features, copy files, setup code access security, and add SafeControl entries to your web.config.&amp;nbsp; Once you create your solution files, build your project and then go to the command line.&amp;nbsp; The utility makecab.exe (should already be on your system) will actually create the wsp file.&amp;nbsp; In the command prompt, go to the root folder of your project and execute the following command.&amp;nbsp; It has to be executed from that folder because all of the paths are relative.&lt;/p&gt; &lt;p&gt;&lt;em&gt;makecab.exe /f solution\cab.ddf&lt;/em&gt;&lt;/p&gt; &lt;p&gt;You can automate this step when you build, by creating a &lt;a href="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2007/08/28/using-msbuild-to-create-a-sharepoint-wsp-file-on-build.aspx"&gt;build action&lt;/a&gt;.&lt;/p&gt; &lt;p&gt;If you are working on a remote server, you will need to copy the .wsp file onto the server. Add and deploy the solution with the following commands.&lt;/p&gt;&lt;pre&gt;stsadm -o addsolution -filename package\MyAssembly.wsp
stsadm -o deploysolution -name MyAssembly.wsp -immediate -allContentUrls -allowGacDeployment
stsadm -o execadmsvcjobs&lt;/pre&gt;
&lt;p&gt;At this point if all goes well, your solution will be installed and deployed.&amp;nbsp; This eliminates all the steps of manually copying files into SharePoint.&amp;nbsp; You can then activate your feature like before (remember it installs the feature for you) and add your web part to a page.&amp;nbsp; If you make an update to your web part, deploying is easy, just use the &lt;em&gt;upgradesolution&lt;/em&gt; stsadm command and it will update all the files in your solution.&amp;nbsp; Should you decide, you don&amp;#39;t need the solution any more, use the &lt;em&gt;retractsolution&lt;/em&gt; command.&amp;nbsp; After you issue either of those commands, you will need to follow it up with a &lt;em&gt;execadmsvcjobs&lt;/em&gt; command as shown above.&lt;/p&gt;
&lt;p&gt;This may sound like a lot, but it really isn&amp;#39;t bad.&amp;nbsp; It makes deployment really easy (especially to other servers).&amp;nbsp; Once you have your solution deployed and you want to make an update, you can also just directly copy out the binary to your server.&amp;nbsp; Not really a best practice, but it does speed things up quite a bit, since stsadm commands take a few seconds to run.&lt;/p&gt;
&lt;p&gt;Once you get the hang of it and are familiar with the deployment process, you really need to consider deploying your solution to the bin folder by deploying your solution under partial trust.&amp;nbsp; Remember right now, you are deploying to the GAC which is not ideal.&amp;nbsp; My post on &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;Code Access Security&lt;/a&gt; walks you through the whole process and provides more details on how solution packages are built.&lt;/p&gt;
&lt;h4&gt;User Controls&lt;/h4&gt;
&lt;p&gt;By now, you may be thinking, I went through all of that and I still have to render stuff to the screen using straight code?&amp;nbsp; I hear you.&amp;nbsp; It&amp;#39;s not any fun at all and can be a &lt;a href="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2008/08/04/to-web-part-or-not-to-web-part.aspx"&gt;controversy&lt;/a&gt; among some SharePoint developers.&amp;nbsp; You do have a couple of alternatives, use the &lt;a href="http://www.codeplex.com/smartpart"&gt;SmartPart&lt;/a&gt; or &lt;a href="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2008/07/30/how-to-build-your-own-smartpart-control.aspx"&gt;write your own&lt;/a&gt;.&amp;nbsp; I typically go with the latter.&amp;nbsp; This simple web part uses Page.LoadControl to load the .ascx file you specify. &lt;/p&gt;
&lt;p&gt;This is quickly becoming the longest post I have ever written.&amp;nbsp; I&amp;#39;ve attached the code I used in this post.&amp;nbsp; You can use it to verify that you put your own web part together correctly or you can use it as a starting point.&amp;nbsp; I hope this provides enough information for a new SharePoint developer to get started.&amp;nbsp; I certainly wish I had this much info condensed in one place when I was starting out.&amp;nbsp; You may also want to check out one of the many solution generating tools out there such as &lt;a href="http://www.codeplex.com/stsdev"&gt;stsdev&lt;/a&gt;.&amp;nbsp; Please leave a comment if this helps or if you have any questions.&amp;nbsp; If I am missing anything or you think I need to add anything, also please let me know.&lt;/p&gt;&lt;img src="http://www.dotnetmafia.com/aggbug.aspx?PostID=751" width="1" height="1"&gt;</description><enclosure url="http://www.dotnetmafia.com/blogs/dotnettipoftheday/attachment/751.ashx" length="25753" 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/Feature/default.aspx">Feature</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/Deployment/default.aspx">Deployment</category><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/Solution/default.aspx">Solution</category></item></channel></rss>