| Adventures In MOSS Land |
This is a place to record my journey with SharePoint. I realized that I was learning a lot of stuff that other people would probably like to know about (and that I would like to refer back to... I'm getting kinda old and my memory is fading.)
- Recent
- Popular
- Tags (0)
- Subscribers (2)
- Managing Key-Value Pair Settings in SharePointJune 1 2008
-
Recently my team discussed various ways to manage application configuration settings in SharePoint. We wanted to avoid using Web.Config files for Key-Value Pair data because of the complexity of managing this data in SharePoint.
SharePoint contains a decent API (SPWebConfigModification) for managing web.config settings across the farm. It works pretty good, but we have had some trouble with it in certain situations. If you are interested in a good article on SPWebConfigModification check out this one by Mark Wagner
Thankfully the folks on the SharePoint development team delivered just what we needed to have a simple solution for managing key-value pair settings. It is the SPPropertyBag class.
SharePoint provides a properties collection for SPFarm, SPWebApplication, SPWebService and SPWeb objects (none for SPSite, but site settings can be stored @ SPSite.RootWeb).
The properties collection for SPFarm, SPWebApplication and SPWebService are not really based on the SPPropertyBag class. The properties collection comes from the derived class SPPersistedObject and is actually a HashTable. But it works exactly the same as SPPropertyBag.
- Creating a SharePoint Web with the APIMay 21 2008
-
I have been working on a application that provides a repeatable way to create sites. This application is very similar to the SharePoint Test Data Population Tool.
One of the first tasks was to create new web applications. A quick look at the API and I thought well this is simple enough.
First instantiate a new instance of SPWebApplicationBuilder. Set some properties on my object and then call create. Use the SPWebApplication.Provision() method and I am done.
Well that is not exactly true. What I discovered was that the Provision method only creates the web application on the local server. This is great for a single web front end, but for a more typical setup more work is required.
So I dug into the Administrative screens using Reflector. I discovered that the SharePoint team is instantiating a timer job that will provision the newly created web on the other web front ends.
if (SPFarm.Local.TimerService.Instances.Count > 1)
{
SPWebApplicationProvisioningJobDefinition definition = new SPWebApplicationProvisioningJobDefinition(application, this.ApplicationPoolSection.ResetIis);
definition.Schedule = new SPOneTimeSchedule(DateTime.Now);
definition.Update();
}So I thought okay this is simple enough. Then I discove
- What is going on in MOSS LandMay 18 2008
-
It has been a while since my last post. I have been heads down working on a large project for my employer. The project is to convert my employers existing MCMS/SharePoint 2003 solution to SharePoint 2007. When this project is over my employer will have one of the largest SharePoint sites in the world.
Stay tuned, I am sure there will be many existing adventures to post about.
- Adventures in extending the Publishing.Fields.LinkValue classMay 18 2008
-
Recently I was working on a SharePoint application that required me to extend the out-of-box Publishing Link field. In the end I found an acceptable solution, but it took a little while to get there.
Inheriting from LinkFieldValue
The first thing I tried was creating a new link field value class that extended the LinkFieldValue class. The LinkFieldValue class is not sealed so I thought I would be able to work with it.
LinkFieldValue inherits from the HtmlTagValue class. HtmlTagValue is more or less a dictionary that provides a structured way to create an HTML tag. Unfortunately HtmlTagValue has all of the routines I needed marked as Internal. So this meant that my idea of inheriting from LinkFieldValue was dead.
The Publishing LinkFieldValue class inherits from the Microsoft.SharePoint.Publishing.Fields.HtmlTagValue class. If you look at the guts of LinkFieldValue you will see that HtmlTagValue does all the
- Problems with XMLNS and SPWebConfigModificationMay 2 2008
-
Recently I posted an article that discussed the SPWebConfigModification. I meant to add some information about problems with XML Namespaces and SPWebConfigModification.
One of the first problems my team encountered with SPWebConfigModification was failures when working with configuration settings that overrode the default xml namespace (xmlns).
The problem arose when we tried to apply the webconfig modifications needed to for the Enterprise Library. Below is a sample entry from the configuration settings needed for Enterprise Library. Notice how the default xmlns is being overridden.
<enterpriselibrary.configurationSettings applicationName="NewsApplication" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.microsoft.com/practices/enterpriselibrary/08-31-2004/configuration" />That one statement invalidates the XPath expressions in the SPWebConfigModification Name and Path properties. This means that SPWebConfigModification cannot successfully find the entry when it scans the web.config file. So every time the web.config file is modified by SPWebConfigModification the entry gets duplicated (which causes the web.config file to be invalid).
A little research into the way .Net Framework handles XML namespaces turned up the XmlNameSpaceManager class. This class is used to define names
