Category Archives: SharePoint

SharePoint stuff, tips & tricks

General

  1. Enable the Windows SharePoint Services Administration to be able to schedule retracting jobs in the Central Admin
  2. Download the newest WSPBuilder bits
  3. Remember to remove the default bin of VS2008 and store the dll’s in 80bin (dll’s in the default bin are going to be deployed to the GAC!)
  4. Add solution to the solution store:

    %STSADMPRG% -o addsolution -filename “..Solution1.wsp”

    (No files available in the 12 hive yet)

  5. Deploy a solution:

    %STSADMPRG% -o deploysolution -name “Solution1” -immediate -force -allowCasPolicies -allowGacDeployment

    (Now you can see the files are added to the 12 hive; features are installed NOT activated)

  6. Activate the feature:

    %STSADMPRG% -o deactivatefeature -filename Feature1feature.xml -url http://ServerName

  7. To enable intellisense with your xml definitions within sharepoint install CAML.IntelliSense.msi
  8. Be sure that the “Windows SharePoint Services Administration” service is running for deploying WSP solutions
Share

Executing WSS in .NET 3.5 mode

By default WSS 3.0 runs under the .NET 2.0 framework. To change this to use the .NET 3.5 framework execute the following steps:

  1. Open the web.config for your site
  2. Add the following assemblies below the tag:
    [sourcecode language=”html”]
    <add assembly="Microsoft.SharePoint, Version=12.0.0.0,
    Culture=neutral, PublicKeyToken=71e9bce111e9429c" />
    <add assembly="System.Core, Version=3.5.0.0,
    Culture=neutral, PublicKeyToken=B77A5C561934E089" />
    <add assembly="System.Xml.Linq, Version=3.5.0.0,
    Culture=neutral, PublicKeyToken=B77A5C561934E089" />
    [/sourcecode]
  3. Then add the following to right before (for example) the tag
    [sourcecode language=”html”]
    <system.codedom>
    <compilers>
    <compiler language="c#;cs;csharp" extension=".cs" warningLevel="4"
    type="Microsoft.CSharp.CSharpCodeProvider, System, Version=2.0.0.0,
    Culture=neutral, PublicKeyToken=b77a5c561934e089">
    <providerOption name="CompilerVersion" value="v3.5" />
    <providerOption name="WarnAsError" value="false" />
    </compiler>
    </compilers>
    </system.codedom>
    [/sourcecode]
  4. Your site now runs under the .NET Framework 3.5!
Share

Use extension methods on your ASPX page

  1. Create a Webapplication project
  2. Edit the Default.aspx to look like this:
    [sourcecode language=”html”]
    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplication2._Default" %>
    <%@ Import Namespace="Berend.PageExtensions" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <html xmlns=http://www.w3.org/1999/xhtml>
    <head runat="server">
    <title></title>
    </head>
    <body>
    <form id="form1" runat="server">
    <div>
    <h1>
    <%=this.MyPageExtensionMethod()%>
    </h1>
    </div>
    </form>
    </body>
    </html>
    [/sourcecode]

  3. Remember to add the namespace (which contains your extension method) to your aspx
  4. Add a class library to your project and code the following class:
    [sourcecode language=”csharp”]
    namespace Berend.PageExtensions
    {
    public static class Class1
    {
    public static string MyPageExtensionMethod(this Page p)
    {
    return "Extension method executed!";
    }
    }
    }
    [/sourcecode]
  5. This class Class1 contains the extension method (remember to make the class and the method static)
  6. Press F5 and your extension method gets executed.

When you want to use this technique with SharePoint 2007 you have to follow the steps in this post to run WSS under the .NET 3.5 framework!

Share

Creating a MOSS 2007 webpart

  1. Start VS 200[5][8] and create a new class library
  2. Sign your class library and determine the publickey token (use reflector.NET for example)
  3. Create a new class in your library with the following code:
    [sourcecode language=”csharp”]
    using System;
    using System.Collections.Generic;
    using System.Text;
    using System.Web.UI.WebControls.WebParts;
    namespace SimpleWebpart
    {
    public class SimpleWebPart : WebPart
    {
    private string displayText = "Hello World!";

    [WebBrowsable(true), Personalizable(true)]
    public string DisplayText
    {
    get { return displayText; }
    set { displayText = value; }
    }

    protected override void Render(System.Web.UI.HtmlTextWriter writer)
    {
    writer.Write(displayText);
    }
    }
    }
    [/sourcecode]

  4. Add the following line of code to your AssemblyInfo.cs: [sourcecode language=”csharp”]
    [assembly: AllowPartiallyTrustedCallers]
    [/sourcecode]
  5. Edit your web.config to add a safecontrol entry (remember to use the public key token as determined in step 2):
    [sourcecode language=”html”]
    <SafeControl Assembly="SimpleWebpart,Version=1.0.0.0,
    Culture=neutral,PublicKeyToken=XXXXXXXXXXXXXXX"
    Namespace="SimpleWebpart" TypeName="*" Safe="True" />
    [/sourcecode]
  6. Copy the class library dll to the bin directory of your webapplication
  7. Create a site collection if not already available
  8. Go to Site Actions –> All settings –> Web parts. Choose New and add your web part to the site gallery.
  9. Edit the page and add your webpart.
Share

Setting up MOSS 2007 search

  1. Create a SSP on a new web application (optional; you can assing your website to an existing SSP)
  2. Change association to use the new SSP
  3. Open the new SSP via Shared Services Administration
  4. Click User Profiles and Properties
  5. Click Full Import
  6. Go back to SSP
  7. Click Search Settings
  8. Click Content Sources and Crawl Schedules
  9. Set “Use this server for serving search queries” enabled (Operations –> Services on Server –> Office Search server”
  10. Be sure that the specified accounts have enough rights to access the websites
Share

Unable to load SharePoint page

When you have webparts on your page that are no longer available SharePoint throws an exception. To remove the webparts from the page that are no longer available navigate to the url

http://YourServer/Pages/[your page in error]?contents=1

Checkout the page; delete the webpart; and check in. Page can be loaded again!

Share

SharePoint stuff

General

  • Enable the Windows SharePoint Services Administration to be able to schedule retracting jobs in the Central Admin
  • Download the newest WSPBuilder bits
  • Remember to remove the default bin of VS2008 and store the dll’s in 80bin (dll’s in the default bin are going to be deployed to the GAC!)
  • Add solution to the solution store: %STSADMPRG% -o addsolution -filename “..Solution1.wsp” (No files available in the 12 hive yet)
  • Deploy a solution: %STSADMPRG% -o deploysolution -name “Solution1” -immediate -force -allowCasPolicies -allowGacDeployment (Now you can see the files are added to the 12 hive; features are installed NOT activated)
  • Activate the feature: %STSADMPRG% -o deactivatefeature -filename Feature1feature.xml -url http://ServerName
Share