Sharepoint Insight by Namwar Rizvi

Sharepoint Tips, Tricks and inside knowledge from real world experience by Namwar Rizvi

Archive for the ‘Object Model’ Category

How to find Microsoft.SharePoint.ApplicationPages.dll and some other assemblies

Posted by namwar on June 12, 2010


You may be wondering where to find Microsoft.SharePoint.ApplicationPages.dll , if you are creating a new SharePoint application page? But don’t worry, it resides in _app_bin folder of your SharePoint site’s virtual directory.

Assuming your IIS inetpub is at C then the exact path of Microsoft.SharePoint.ApplicationPages.dll is

C:\Inetpub\wwwroot\wss\VirtualDirectories\<Your Virtual Server >\_app_bin\Microsoft.SharePoint.ApplicationPages.dll

Here is the full list of assemblies at _app_bin folder:

  1. Microsoft.Office.DocumentManagement.Pages.dll
  2. Microsoft.Office.officialfileSoap.dll
  3. Microsoft.Office.Policy.Pages.dll
  4. Microsoft.Office.SlideLibrarySoap.dll
  5. Microsoft.Office.Workflow.Pages.dll
  6. Microsoft.Office.WorkflowSoap.dll
  7. Microsoft.SharePoint.ApplicationPages.dll
  8. STSSOAP.DLL

Posted in Information, Object Model, Tips, Troubleshooting | Tagged: , , , , | Leave a Comment »

Verify your code with SharePoint Dispose Checker Tool

Posted by namwar on February 2, 2009


Today, a new tool  SharePoint Dispose Checker Tool  has been released at MSDN for checking your code against incorrect processing of IDisposable objects like. SPSite and SPWeb. This tool checks your assembly and identify potential problems of not disposing these objects. 

You can download SharePoint Dispose Checker Tool from here

and here is the great article from Paul Andrew (Microsoft Technical Product Manager for the SharePoint Developer Platform) about best practices and how to use this tool.

Posted in Bugs, Debugging, Object Model, Tools | Tagged: , , , , , , | Leave a Comment »

Update List Item without changing Modified By and Modified fields

Posted by namwar on September 30, 2008


If you update a field of a SPListItem obeject from code by using the following code snippet

item[“Title”]=”Updated Title”;

item.Update();

then you will notice that Modified By  and Modified field will be updated also. Sometimes, you just want to update fields without changing Modified By and Modified fields, you can do so by using 

item.SystemUpdate();

instead of item.Update();

SystemUpdate() method just updates the intended field values.

Posted in Object Model | Tagged: , , | Leave a Comment »

How to check if the file is indexed in SharePoint or not?

Posted by namwar on September 17, 2008


If you want to know whether your file is indexed in Sharepoint Search Services Provider (SSP) or not then there is no way provided directly in the object model of SSP.

Since Sharepoint stores its content on SQL Server therfore, you can run the following TSQL query to find it:

Select * from dbo.MSSAnchorText where Link='<Your File Path>'
Note: Please note you need to replace <Your File Path> by the full path of the your intended file in the above query
Example
Select * from dbo.MSSAnchorText where Link='http://mossdev/Shared%20Documents/UserManual.pdf'

Posted in Object Model, SSP | Tagged: , , , , | Leave a Comment »

SPDiffUtility: An excellent class to find differences in strings with HTML highlighting

Posted by namwar on August 25, 2008


While exploring Sharepoint utility classes, I found an excellent class which deserve more credit then it currently enjoys. It is SPDiffUtility. This class has only one static method called Diff which determines the text differences between two strings. It takes three parameters:

  1. str1: The original string
  2. str2: The changed string
  3. maxDifferences: A 32-bit integer representing the maximum number of differences to find.

The beauty of this function lies in its return value which is a merged version of the specified strings that contain HTML tags indicating inserted, deleted, or changed text.

This returned string contains HTML tags to highlight the changes, insertions and deletions. The best part is that you can set these tags with your HTML tags if you want. Following is the sample usage of this class.

  1. Create a web site project in Viusal Studio
  2. Add reference to Microsoft.Sharepoint.dll found in C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\ISAPI\Microsoft.SharePoint.dll
  3. Paste the following code in Default.aspx
  4. <%@ Page Language=”C#” AutoEventWireup=”true” CodeFile=”Default.aspx.cs” Inherits=”_Default” %>
    <!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”&gt;
    <html xmlns=”http://www.w3.org/1999/xhtml”&gt;

    <head runat=”server”>
    <title>Untitled Page</title>
    </head>

    <style type=”text/css”>
    .ms-diffdeletenostrike {
    BACKGROUND-COLOR: #e0e0e0;
    }
    .ms-diffdelete {
    BACKGROUND-COLOR: #e0e0e0;
    }
    .ms-diffdelete {
    TEXT-DECORATION: line-through;
    }
    .ms-diffinsert {
    BORDER-RIGHT: #ffffff 1px solid;
    BORDER-TOP: #ffffff 1px solid;
    = BORDER-LEFT: #ffffff 1px solid;
    BORDER-BOTTOM: #ffffff 1px solid;
    = BACKGROUND-COLOR: #ffeaad;
    }
    </style>
    <body>

    <form id=”form1″ runat=”server”>
    <div>
    <asp:Label ID=”lblResult” runat=”server” Text=””></asp:Label>
    </div>
    </form>

    </body>

    </html>


  5. Open Default.aspx.cs and paste the following code

  6. using System;
    using System.Configuration;
    using System.Data;
    using System.Linq;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.HtmlControls;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Xml.Linq;
    using Microsoft.SharePoint.Utilities;
    using System.Diagnostics;

    public partial class _Default : System.Web.UI.Page
    {
    protected void Page_Load(object sender, EventArgs e)
    {
    string firstString = “This is an initial string”;
    string secondString = “This”;

    //Set the tags
    SPDiffUtility.ChangeOpenTag = ““;
    SPDiffUtility.ChangeCloseTag = “
    “;
    SPDiffUtility.InsertOpenTag = ““;
    SPDiffUtility.InsertCloseTag = “
    “;
    SPDiffUtility.DeleteOpenTag = ““;
    SPDiffUtility.DeleteCloseTag = “
    “;

    //end setting tags

    //Find the difference
    string diffString = SPDiffUtility.Diff(firstString, secondString, Int32.MaxValue);
    lblResult.Text = diffString;

    }
    }

  7. Run web application by pressing Ctrl+F5

You will see “This is an intial string where striked out letters are those which have been deleted in the second string.

Posted in Object Model | Tagged: , | 2 Comments »

How to find End Date Pattern in Sharepoint Recurring Event

Posted by namwar on August 18, 2008


Sharepoint recurring events are similar to Outlook recurring events and provides several options to specify End Date pattern. If you find the type of End Date pattern in a recurring event you can find it in AfterProperties field of SPItemEventProperties object. Just check following

AfterProperties[“RecurrencePattern#EndDateRangeType:fRecurrence”]

Following are possible outputs and their meaning

  • 0   No end date.
  • 1   End after a specified number of occurrences. Requires that RecurrencePattern#repeatInstances:fRecurrence be specified.
  • 2   End by a specified date. Requires that RecurrencePattern#windowEnd:fRecurrence be specified.

Posted in Event Handler, Object Model | Tagged: | Leave a Comment »