Tuesday, August 26, 2008

The Case of the Missing Icons

In a recent attempt to add some new filetype icons to SharePoint, I stumbled across an interesting problem... duplicate entries in the icon lookup file (...\12\TEMPLATE\XML\DOCICON.xml) cause icons to disappear, with the alt text "Item Icon" in their place. In my case, I added a Photoshop (.psd) icon for some of our designers. But, just like this guy, I quickly realized that SharePoint already has one. A duplicate entry will break icons in lots of places (search, for example), so edit with care.

Unicode Reference

When using SharePoint sometimes you run into a URL with lots of unicode character markup. Here's a good reference so you can figure out what the h%65ck it all means.

Monday, August 25, 2008

List Types and Base Types

Here's a good reference that I've been using for the all the List Types and BaseTypes:

Wednesday, August 20, 2008

Bulk MySite Creation

Because SharePoint will display active links to MySites that might not exist, I was asked to "pre-create" all of the MySites before an upcoming rollout to prevent any confusion from "broken" links. I found a tool at codeplex called TIN that seemed to do what I needed, but it was a little clunky so I rewrote it. The new version is incredibly simple, but it might save somone some time so I thought I'd share. Basic features include:
  • Bulk creation of MySites for entries in the ProfileManager
  • Bulk deletion of MySites for entries in the ProfileManager
  • List profiles from the ProfileManager and whether they have a MySite
  • Robust logging and error handling
  • Save-to-File for log results
  • Multiple threads for long-running operations and smoother screen updates
The source code isn't so beautiful, but here it is. Feel free to make any changes you like, and let us know if it worked for you. Also, if you do make changes and want to share, just send it in and we'll post an update.

Here's a shot of it in action:

Note: Generating a large number of personal sites can take a while, so you may want to run this sometime off-peak.

Tuesday, August 19, 2008

"This solution contains no resources scoped for a Web application and cannot be deployed to a particular Web application." in STSDEV

I recently created a Web Part based on the STSDEV Web Part project and found it was very simple to use. I had another Web Part to create but this time I decided to go with the more generic 'Empty Solution' project just to ensure I wasn't getting lazy with all the stuff STSDEV does for me. The project built, and installed properly into the solution store, but doing a 'DebugDeploy' failed with an error.

I compared the two projects and they seemed to be configured identically. However upon further inspection, I found that the 'DebugDeploy' section of the Web Part Project (STS DEV generated) is different than the 'DebugDeploy' section of the empty solution. changing this line:

<Exec Command="$(STSADM) -o deploysolution -name $(PackageName) -immediate -allowgacdeployment" />

to:

<Exec Command="$(STSADM) -o deploysolution -name $(PackageName) -immediate -allowgacdeployment -allcontenturls" />

solved the problem.

NOTE: you'll also want to update the retract solution command to this:

<Exec Command="$(STSADM) -o retractsolution -name $(PackageName) -immediate -allcontenturls" ContinueOnError="true" />

Activating SharePoint Publishing Infrastructure Results in 'Access Denied'

I was getting a 'Access Denied' error when trying to activate the SharePoint Publishing Infrastructure feature. I found two solutions. The first involved changing the Application Pool that Central Admin ran under. The second, found here, simply involves running an STSADM command from the command line. In a production system, I'd say that the stsadm way to go (it's also faster).

Thursday, August 14, 2008

SharePoint Slow?

Joel Oleson's blog has a great post on dealing with the slowness on first page request we've all dealt with.

Web Part Styles

There are many examples of how to create a web part. However the best way to style web parts is not necessarily well documented, so I thought I'd offer up my approach and see what the community thinks.

Basically I create my web part as a feature in a solution. Then, if my web part generates any code that requires styling I add a .css file to my feature directory. Next I provision the stylesheet of my web part to a folder within my site's "Style Library". Finally I add the code into my web part to add the stylesheet ("<link>") link to the header of the page that my web part has been dropped on.

Most of the stuff is straightforward but here's how to provision a style sheet to the style library:

  1. Add a "provisioning.xml" file to your feature and reference it in the ElementManifest section of Feature.xml
  2. in "provisioning.xml" enter the following:

    <?xml version="1.0" encoding="utf-8" ?>
    <Elements xmlns="http://schemas.microsoft.com/sharepoint/">
    <Module Name="JumpToItemDropDownStyles" Url="Style Library/en-us/Core Styles/WebPartStyles" Path="Styles" RootWebOnly="TRUE">
    <File Url="JumpToItemDropDown.css" Type="GhostableInLibrary" IgnoreIfAlreadyExists="TRUE" />
    </Module>
    </Elements>
And here's how to add your style sheet reference dynamically:

In your webpart code (I do it in CreateChildControls) add the following code:

try
{
ContentPlaceHolder header = (ContentPlaceHolder)this.Page.Master.FindControl("PlaceHolderAdditionalPageHead");
if (header != null)
{
CssRegistration cssControls = new CssRegistration();
cssControls.Name = "The Url To Your Provisioned CSS file";
header.Controls.Add(cssControls);
}
}
catch (Exception ex)
{
throw new Exception("CSS Registration Error.

details:
" + ex.Message);
}

Tuesday, August 5, 2008

WebPart Error: [ArgumentException: The serialized data is invalid.]

You may run into this problem. In my case I had a legitimate serialization error, but when I took out the offending code I was still getting the same error.

I found the solution is to close/readd the webpart to eliminate the error.