I am in the process of getting up to speed with the new Visual Studio 2010 IDE and how it can be used to develop custom SharePoint 2010 solutions.
It’s so easy to do a “Hello World” Web part project now. These days, my Hello World projects typically involve opening up a database table and displaying records in a table. I was able to do this with minimal coding and got it up and running—a full blown Web part—in under 15 minutes!
I created a sample project that opens up the AdventureWorks database and displays employee records in a table:

Sample Visual Web Part Project using Adventure Works Database
The Web-part looks like the following when used inside SharePoint:

AdventureWorks Employees Web Part So far, I like it!Here are my first impressions:SharePoint project templates come out-of-the-box install of VS 2010. After installing VS 2010, the SharePoint project templates are ready for use. No need to do installations of VS-extensions.SharePoint Project Templates in Visual Studio 2010
- The Visual Web Part project cannot be deployed as a “sandboxed solution”. It has to be deployed as a farm solution.
- Project-debugging became a lot easier even with a full-blow farm-deployment. Press F5 in the VS 2010 IDE and Visual Studio will build, package, deploy, and activate your feature, and launch the debug-browser all in one click! When you’re done debugging, terminate Internet Explorer, Visual Studio will deactivate and retract the solution out of SharePoint.
- IIS-reset (for the target Web app) even for full-blown deployments when debugging is fast!
- Remember in VSeWSS 1.3 where you had to Google first how to specify the group the Web part appears in because it wasn’t so obvious? Well, it got easier in VS 2010! Now, the Elements.xml file has a place-holder for the Web-part group. All you have to do, is change it from “Custom” to whatever value you want it to be. It’s so visible now you can’t miss it.

Web-Part Group Place-Holder in Elements.xml File
- You can now add Web User Controls (ASCX files) into the project! As a matter of fact, the project template adds one ASCX file for you. This just made Web Part development a HECK of a lot easier! This is HUGE! Back in VS 2008 developing SharePoint 2007 Web parts, there were no designers available. If developers wanted to use ASCX files, they had to create regular ASP.NET Web apps, design the ASCX files there, write the code-behind, compile the project so the code-behind logic gets packaged with the ASCX files, deploy the ASCX files to UserControls folder within the SharePoint virtual Web app folder, deploy and enable Smart Part, add a Smart Part Web part to the SharePoint pages, then finally, hook-up the Smart Part to the ASCX files. Whew!!! Talk about LOTS of steps! In VS 2010, you don’t need Smart Part or that lengthy way to integrate ASCX file in SharePoint anymore. The challenge of “imagining” what your Web part will look like as you write your C# code is no more. The designer is built in to the Visual Web Part project. Leverage your ASP.NET skills to the max.
- Despite all the improvements, Web part development veterans should recognize familiar concepts and project files such as Elements.xml, .webpart file, strong-named key file, packages and features.
I have many ASP.NET developer friends who didn’t want to get into SharePoint development because:
- The Web part project wasn’t easy in SharePoint 2007. No designers, hard to design a visual element.
- ASP.NET developers got accustomed to easy debugging of their projects by simply pressing F5 key or the play button on the IDE toolbar. In 2007, ASP.NET developers thought deploying the app and then attaching to the w3wp.exe process (multiple manual steps, not one) was too cumbersome.
- It took forever to even debug the code because the SharePoint Web app always recycled on deployments.
If you are an ASP.NET developer contemplating if you should try SharePoint development, I highly recommend you try it NOW! SharePoint 2010 development feels like traditional ASP.NET development more than ever!
If you are a .NET developer and if you happen to also have a Mac environment, I highly recommend that you learn iPhone development. Why? Read on.
I purchased a Macbook Pro a week ago and started coding an app within the first 2 hours of getting home! I tell you what, I’ve been a PC for a long, long time and a first-time Mac owner. This Macbook Pro Unibody plus the Snow Leopard OS is a really one sweet device. Am I done with PC laptops? Nope–I’m just waiting for the HP Envy 14 series to come out–16Gb RAM config with newest iCore 7 chip plus SSD drives–that’s going to be my configuration for SharePoint 2010 mobile development. Anyway, back to the Macbook. So, I started coding my first night owning the Mac. I saw some samples on the Web and started coding iPhone apps. Holy-moly! I saw and typed keywords that I haven’t used since college (I think)–the malloc and dealloc commands/keywords!!! I dreaded those things as a young programmer. Memory leaks, buffer overruns–yep, I got burned many times when I was starting out and I didn’t allocate/deallocate memory properly in my programs.
So, what does iPhone development got to do with .NET development? Well, technology-wise, they are different worlds. XCode uses Objective-C while .NET (mostly) uses C#. They’re kind of like distant cousins; they’re similar in some ways but different in many ways. No, I’m not recommending you abandon .NET and totally convert to XCode. I’m recommending that you try iPhone development because it will bring you back to fundamentally sound programming practices. As a developer, I felt like it brought me back to my roots. Developers need to be mindful of performance and memory use when developing for the iPhone. In XCode and .NET, there are garbage collectors. Developers don’t worry about memory-allocation thanks to the garbage-collectors. iPhone apps don’t have garbage-collectors. Also, device memory is limited on the iPhone. No gigs of RAM. No swap files. Should you try iPhone development, you will see malloc and dealloc again and you will be constantly asking yourself “maybe I should clean-up stuff in memory and make room for new objects”. If you’ve never seen malloc and dealloc, we’ll I hope it’s a fun experience discovering for the first time what it’s like to develop where you are constrained by limited memory.
.NET developer with a Mac: go try iPhone development. If anything, because you’re forced to think limited CPU cycles and limited memory, it should improve your overall programming skills!
We had a previous SharePoint project where we installed a custom HTTPModule to the SharePoint Web application. Since the SharePoint manifest file cannot inject entries into the httpModules section of the Web.config file (the manifest file can only insert entries inside the SharePoint section of the Web.config such SafeControl entries), we had to use a custom feature-receiver class, based on the SPFeatureReceiver. The custom feature-receiver class did it’s job nicely; whenever the feature got activated, the required entry in the httpModules section of the Web.config file got inserted.
Sequence property of the WebConfigModification can be used to figure out the uninstall order.
Unnamed sections such as connectionStrings and bindings sections, appear to have an XPATH expression that may result in duplicate matching. But, the ApplyWebConfigModifications method of the WebConfigModifications object will do it correctly as long as:
- EnsureChildNode is used as the type
- Add/Remove in order that is logical. Example: add connectionStrings section first then the add elements inside the connectionString section.
- If you are worried that de-activating a feature will obliterate the connectionStrings section because your feature created it, don’t. SharePoint will only take out the connectionStrings if there are no other entries created by the ApplyWebConfigModifications inside the connectionStrings section. If other features inserted 1 or more connection-string entries there, your feature-receiver will not remove the connectionStrings section. Now, if the connectionString section got edited manually, the SharePoint WebConfigModifcations object will not know this and it doesn’t matter how many child-nodes there are inside the connectionString object. The root element (connectionString) in this case will be removed because in SharePoint’s perspective, there are no existing Web-config modifications inside connectionString.
Conclusion: if you are going to adopt feature-receivers to install web.config entries such as connection-strings and bindings (for Service-References), you must also adopt to policy to discourage manual insert/modification of the web.config entries. Be consistent.
Newer Posts »