Well, I'm back... they finally coughed up the ransom! Truthfully, I've been busy and have wanted to put this particular post together for some time. Since It's still a work in progress, I decided to divide it up into a series. That way I can't procrastinate any further! I have limited experience with SharePoint development in general. I have never created a custom CAS policy and I am using the 1.3 version of the VS extensions for the first time, so it should be interesting.
Many developers are overwhelmed by the plethora of tools out there right now for creating and deploying simple components in SharePoint. My personal favorite so far has been STSDEV although I had some problems with the most recent version. At the end of the day, I decided to either hand-roll my Web Parts and deploy with STSADM, or use the Visual Studio Extensions. The reason a lot of people have used tools other than VSeWSS is because the the extensions have been considered pretty limited up to now. But that seems to be changing and version 1.3 has some really cool features.
You can download the extensions, both 32 bit and 64 bit, as well as the pre-release notes. Uninstall version 1.2 first, if you already have it installed.
We're going to take the new 1.3 CTP of Visual Studio Extensions for VS 2008 for a test drive. We will create a custom Web Part which will display some data from an XML file. We will deploy our Web Part to the bin folder rather than than to the Global Assembly Cache (GAC); deploying to the GAC involves resetting IIS which is impractical if you have a production environment with a single Web Front End (WFE) server. In order to run this code from the bin folder, we will create a custom code access security (CAS) policy.
When you opt to create a new Web Part project, you will be presented with the New Project dialog box. Opt to deploy to the bin folder. Your Solution Explorer window and WSP View should now resemble those in the diagrams shown.
In the next part, we'll take a look at the architecture of Features in general; the aim is to keep this as simple as possible and get something up and running. The most common problems people are having are security-related. We will look at this more closely and set out the steps necessary to enable your code to run in a secure environment. In the meantime, you can study up on the use of Features.
If you are in the business of deploying SharePoint Web Parts to the bin directory, then this little titbit may save you some time. In order to add a <SafeControl> entry to the Web.config file, you need to create something like this in the <SafeControls> section:
<SafeControl Assembly="SecureLinks, Version=18.104.22.168, Culture=neutral, PublicKeyToken=9f4da00116c38ec5"
You need to obtain the PublicKeyToken and the way to do this is to run the sn.exe command-line utility. Right-click on the Visual Studio command prompt and select "run as administrator". Change your path to: C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin>. This is where the elusive sn.exe resides!
Now you can call it using: sn.exe -T C:\inetpub\wwwroot\wss\VirtualDirectories\80\bin\SecureLinks.dll. Substitute your own port number and Web Part name; my port was 80 and the Web Part was called SecureLinks. Also, make sure this is actually a capital "T". Running this command should return something like this: Public key token is 9f4da00116c38ec5.
Apologies for not posting for so long. This is just a quick update of
what I've been up to and what I'll be blogging about in 2008. First
off, there have been two new additions to the family, as shown in the
picture. We got Tripper
(Tripper Grace, not to be confused with Tipper Gore) as a nine-week old
puppy in Northern California and he is still being housetrained! The
other addition was a Rory Gallagher 1961 Stratocaster, hand-made by Fender.
I'm in the process of setting up the new SharePoint Intranet for the
County where I work. As part of the training, a team of us attended the
DevConnections conference last month in Las Vegas. The most informative session for me was the "Structured Approach to Building MOSS 2007 Publishing Sites"
given by Andrew Connell. My goal is to have a repeatable deployment
model which lends itself to source control. In addition, I'm looking to
have a comprehensive backup and restore process. By comprehensive, I
mean one which takes into account such missing pieces as customization,
Web Parts and the IIS metabase. This is an ongoing task for me right
now. But Andrew's presentation brought me a lot closer. Chapter 4 of Real World SharePoint 2007 was penned by Andrew and gives a good insight into Feature-based deployment.
SharePoint is one big jigsaw with a couple of pieces missing. The real
task is identifying these missing pieces and not blindly trusting the
OOTB functionality. This is true whether you are creating a development
environment or a backup and restore process. I will blog more about my
experiences in the coming months.