Tag Archives: sharepoint

SharePoint can not debug assemblies

If you are ever having problems getting Visual Studio to break into your code and you develop by deploying your dll’s into the GAC, it’s probably down to mismatching PDB’s.

  1. Do a Clean Solution
  2. Rebuild the solution
  3. Re-Gac all your dll’s
  4. Reattach to IIS processes

Other hints

Locked files in the GAC

Some times a process will take a lock on an assembly and if, like me, you use WSPBuilder to re-gac your assemblies, you might not notice that it fails to re-gac them. Crack open process explorer, find the rogue process and “Get Some”. Usually Visual Studio is the culprit here.

Tagged ,

Shared Services Administration: Add Audience Rule – No exact match was found. Error

Trying to setup an audience this morning based on being a “Member Of” an Active Directory group. The Active directory group had been created earlier, however entering it into the value field kept producing the annoying

 

No exact match was found.

Your mileage may vary but I solved this issue by:

  • Running a full import on my user profile
  • Updating the people scopes
  • Running an IISRESET
Tagged , ,

How to add an image web part / ImageWebPart part via your onet.xml or elements manifest

<AllUsersWebPart WebPartZoneID="RightZone" WebPartOrder="4">
  <![CDATA[
      <WebPart xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.microsoft.com/WebPart/v2">
        <Title>Employee Emergency Line</Title>
        <FrameType>None</FrameType>
        <Description>Use to display pictures and photos.</Description>
        <PartImageSmall />
        <PartImageLarge>/_layouts/images/msimagel.gif</PartImageLarge>
        <Assembly>Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c</Assembly>
        <TypeName>Microsoft.SharePoint.WebPartPages.ImageWebPart</TypeName>
        <ImageLink xmlns="http://schemas.microsoft.com/WebPart/v2/Image">/SiteCollectionImages/logo.gif</ImageLink>
        <AlternativeText xmlns="http://schemas.microsoft.com/WebPart/v2/Image" />
        <VerticalAlignment xmlns="http://schemas.microsoft.com/WebPart/v2/Image">Middle</VerticalAlignment>
        <HorizontalAlignment xmlns="http://schemas.microsoft.com/WebPart/v2/Image">Center</HorizontalAlignment>
        <BackgroundColor xmlns="http://schemas.microsoft.com/WebPart/v2/Image">transparent</BackgroundColor>
      </WebPart>
   ]]>
</AllUsersWebPart>

Properties of note:

  • ImageLink
    Url to image, can be relative. Note tokens are supported in this xml element, i.e. ~SiteCollections/SiteCollectionImages/logo.gif
Tagged , , ,

How to add a content editor web / ContentEditorWebPart part via your onet.xml or elements manifest

 
<AllUsersWebPart WebPartZoneID="TopZone" WebPartOrder="2">
![CDATA[                     
	<WebPart xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.microsoft.com/WebPart/v2">
        <Title>Web part title</Title>
        <FrameType>None</FrameType>
        <Description>Web part description</Description>
        <FrameState>Normal</FrameState>
        <Assembly>Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c</Assembly>
        <TypeName>Microsoft.SharePoint.WebPartPages.ContentEditorWebPart</TypeName>
        <ContentLink xmlns="http://schemas.microsoft.com/WebPart/v2/ContentEditor" />
        <Content xmlns="http://schemas.microsoft.com/WebPart/v2/ContentEditor">
         &lt;div class=&quot;ms-sblink&quot;&gt;
           &lt;a href=&quot;javascript:HelpWindowKey('how_content_is_searched')&quot;&gt;
             $Resources:spscore,PrivacyStatementWP_LinkText;
           &lt;/a&gt;
        &lt;/div&gt;
        </Content>
        <PartStorage xmlns="http://schemas.microsoft.com/WebPart/v2/ContentEditor" />
		</WebPart>             
  ]]> 
</AllUsersWebPart>

The important part here is to remember to html encode the Content element. You can encode html online using this handy website: http://www.opinionatedgeek.com/dotnet/tools/htmlencode/Encode.aspx

Tagged , , ,

How to add a list view web part to onet.xml or your elements manifest

     

 <View List="Lists/Registrations" BaseViewID="3" DisplayName="Pending Registrations" Name="Pending Registrations" RecurrenceRowset="TRUE" WebPartZoneID="Left" WebPartOrder="1">
  <![CDATA[
             <WebPart xmlns="http://schemas.microsoft.com/WebPart/v2">
                  <Assembly>Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c</Assembly>
                  <TypeName>Microsoft.SharePoint.WebPartPages.ListViewWebPart</TypeName>
                  <Title>Pending Registrations</Title>
             </WebPart>
      ]]>
</View>

BaseViewID: Optional Integer. Specifies the ID of the base view. BaseViewID has a corresponding property on SPView

For more information hit up MSDN: http://msdn.microsoft.com/en-us/library/ms441170.aspx

Tagged , , , ,

SharePoint Page layout throws “Parser Error Message: Only Content controls are allowed directly in a content page that contains Content controls” during provisioning.

If you see something like this:

Line 42:     </WebPartPages:WebPartZone>
Line 43: </asp:content>
Line 44: <html xmlns:mso="urn:schemas-microsoft-com:office:office" xmlns:msdt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882"><head>
Line 45: <!--[if gte mso 9]><xml>
Line 46: <mso:CustomDocumentProperties>

This could be (it was in my case) caused by a very obscure behaviour of the web part manager during provisioning. Namely it doesn’t like your <asp:Content tags to be defined in lower case.

Wrong: Error prone page layout

</p>

<p><asp:content…</p>

<p>

Correct

</p>

<p><asp:Content…</p>

<p>

Yet another SharePoint time waster! 🙂

Tagged ,

Performance profiling SharePoint sites using Redgate ANTS Profiler

I used the 5.0 evaluation copy of  RedGate ANTS profiler tool on a standard Windows Sever 2003 R2 / SharePoint 2007 virtual machine.

To get profiling working with my SharePoint code base I made the following adjustments:

  • Allow site collection administrator to “Act as part of the operating system” and “Impersonate a client after authentication” and to Administrators group – All this was already the case.
  • Run “ANTS Performance Profiler 5 Service” and “ANTS Memory Profile 5 Service” under the site collection administrator account
  • Copied my applications dll’s and pdbs from GAC to web application bin folder, as I was previously using the GAC.

A complete guide to setting up ANTS profiler with SharePoint

The ANTS profiler is extremely easy to use and it quickly helped me narrow down some issues using XlstCompiledTransform objects.

Tagged ,

The template you have chosen is invalid or cannot be found.

I lost 3 hours of my life to a stupid collision of template ID’s. Creating a site collection or child web based on one of my custom templates kept failing with the following UI error message

"The template you have chosen is invalid or cannot be found."

The SharePoint logs were less than helpful:

02/15/2009 14:32:22.97     output.exe (0x10CC)                         0x1E14    Windows SharePoint Services       General                           72k2    High        Failed to apply template "xxxxxx#0" to web at URL http://xxxxxx/sites/test2, error The template you have chosen is invalid or cannot be found. 0x81071e44    

02/15/2009 14:32:22.97     output.exe (0x10CC)                         0x1E14    Windows SharePoint Services       General                           8kh7    High        The template you have chosen is invalid or cannot be found.  

Solution:

Make sure all of the site definition configurations located in %programfiles%\Common Files\microsoft shared\Web Server Extensions\12\TEMPLATE\1033\XML have a unique IDs. Microsoft suggests ID values above 10000 to avoid conflicts with future Microsoft supplied site definitions (http://msdn.microsoft.com/en-us/library/ms441616.aspx). Most custom site definitions therefore use 10001 and if two site definitions have the same ID you wind up wasting several hours trying to figure out why it’s not provisioning your site definition.

Tagged

Unit testing for SharePoint

Typemock are offering their new product for unit testing SharePoint called Isolator For SharePoint, for a special introduction price. it is the only tool that allows you to unit test SharePoint without a SharePoint server. To learn more click here.

The first 50 bloggers who blog this text in their blog and tell us about it, will get a Full Isolator license, Free. for rules and info click here.

Continue reading

Tagged ,

SharePoint + picture frame = continuous monitoring

Inspired by Owen Roger’s recent appearance on Hanselminutes, I decided to pick up a picture frame and give it some SharePoint integration love. I went for the Samsung SPF-72V (Actually a birthday present from my brother – thanks!)

Samsung SPF-72V picture frame

Importantly this picture frame supports WIFI and viewing of pictures from any RSS feed. I almost bought the Kodak Easyshare however this does not support arbitrary photo feeds, only those from Kodak’s own picture site [sigh].

Business Key Performance Indicators

My first integration idea centered around the KPI capabilities built into the new version of SharePoint 2007.

SharePoint Kpi WebPart

Why would you want to display KPI’s them in a picture frame anyway? Perhaps to increase the visibility, share the responsibility of the KPI’s and to make the information more accessible.

Prototype

I decided to make a graphical representation of the SharePoint KPI list using GDI+, each time one of the lists KPI’s was updated. Then save the result in a SharePoint picture library. The picture frame would be pointed at the picture library’s RSS feed displaying the latest graphical representation of the KPI list.

sharepoint_continuous_monitoring_system_activiy

1. Updating the image

I extended the KPI base column indicator content type using a feature and hooked the ItemUpdated event

<Elements xmlns="http://schemas.microsoft.com/sharepoint/"> <ContentType ID="0x00A7470EADF4194E2E9ED1031B61DA0884" Name="Common Indicator Columns"> <XmlDocuments> <XmlDocument NamespaceURI="http://schemas.microsoft.com/sharepoint/events"> <spe:Receivers xmlns:spe="http://schemas.microsoft.com/sharepoint/events"> <Receiver> <Name>KpiEventReceiver</Name> <Type>ItemUpdated</Type> <SequenceNumber>10000</SequenceNumber> <Assembly> KpiFrameSolution, Version=1.0.0.0, Culture=neutral, PublicKeyToken=6ba389ff4c4c60ec </Assembly> <Class>KpiFrameSolution.Code.EventHandlers.KpiEventHandler</Class> <Filter></Filter> </Receiver> </spe:Receivers> </XmlDocument> </XmlDocuments> </ContentType> </Elements>

In KpiEventHandler I extract the KPI information for the list to which the item being updated belongs. Unfortunately this is where some of the madness began. The kpi status field which indicates red/yellow/green is always null i.e. field["KpiStatus"] = nada. To make matters worse if the column is not a static kpi the Value field is also empty.

Okay so fire up reflector and see how the SharePoint KPI WebPart is able to work out all these values.

Turns out there is a nice factory class KpiFactory that returns a Kpi class for a given list item:

public static Kpi GetKpi(SPListItem listItem);

Using the Kpi class we can obtain a reference to the KPIData class and finally get our grubby hands on the value, status and trend.

public KPIConsts.KPIData GetKpiData();

// Note requires HttpContext

Slight problem KpiFactory is marked as internal – doh. Oh well that’s why they invented reflection. Seeing as the out-of-the-box KPI WebPart is allowed to call into this factory class, why can’t I? So I do obtaining the type like so:

Type kpiFactoryType = System.Reflection.Assembly.GetAssembly(typeof(KpiDisplayFormControlBase)).GetType("Microsoft.SharePoint.Portal.WebControls.KpiFactory", true);

Once you’ve grabbed all of the KPIData it’s just a question of drawing some pretty pictures to represent the list. Because of my crap design skills lack of time, I just copied the HMTL version of the list using the System.Drawing classes to mimic the original.

Image2

System.Drawing representation of the KPI list

2. Publishing the RSS feed

What could be easier I thought? Just turn on anonymous access to the picture library, enable the feed – using enclosures of course 🙂 and we will be up and running on the picture frame looking at our glorious KPI’s

WindowClipping (7)

WindowClipping (8)

Didn’t work, the picture frame wouldn’t display my images, but flickr feeds worked fine, hmm. So I implemented a custom SharePoint feed that used the same media rss specification that flickr outputs. No joy. Still no image displaying.

Starting to get sick of this bloody picture frame… Suspecting that the picture frame couldn’t read the .net generated images I copied some of the flickr images into the SharePoint image library. Low and behold the flickr images appeared but mine still weren’t appearing.

Long and the short  it, after what felt like a day’s worth debugging (read couple of hours), the solution was embarrassingly simple. The picture frame ignores images that are of significantly lower size than the devices 800 x 480 screen resolution. And because this was a prototype, I hadn’t bothered to great a large complete image, rather I just created a 300×200 graphical representation of the list. Once I bumped the image size to 800 x 480 every thing worked fine, or did it?

sharepoint_continuous_monitoring_photo_frame_complete

Looks much better in real life –

sharepoint_continuous_monitoring_photo_frame_zoom

– as I’m rubbish at photography.

Final gotcha

The Samsung SPF-72V doesn’t seem to reload the RSS feed, unless manually prompted to do so. Even using my custom SharePoint RSS feed with a <ttl>1</ttl> had no effect. The device simply cached the initial pull from the RSS and looped those first set of images (also loading the images from cached memory).

Solution: Turn off the picture frame’s local storage – uncheck the tick box highlighted in red. Then always create two images with same names, the frame then cycles between the two images always requesting them from the server each time.

Note turning off caching does not cause the RSS to get reloaded just causes the images to be pulled from the server every time they are displayed. If you only have one image in the feed, this will not get reloaded, hence the need for two.

sharepoint_continuous_monitoring_photo_frame_storage

Next steps

  • Improve the image, make it larger, add more fidelity.
  • Make the source code more configurable, a couple of places were hard coded to get this up and running quickly

Source code

  • If you interested I’ve attached the source code used for this prototype. It’s not really fit for public consumption from an installation point of view (and some of the hard coded URLs)

SharePoint Picture Frame Continuous Monitoring Source Code (978kb)

Tagged , ,