Monday, February 08, 2010

Setting up PHP and Eclipse IDE for debugging on IIS7.

Here are the steps required to setup PHP on IIS7 and configure Eclipse IDE for debugging:
1. To install PHP on IIS7 you can either download the PHP installer from http://php.net/downloads.php or use Microsoft Web Platform installer. If you are installing PHP directly without using Microsoft Web Platform installer make sure you install the non thread safe version. The web installer automatically install the correct version. Also, on the window to select the web server, select IIS FastCGI.
2. Download and install Eclipse for PHP developers from http://www.eclipse.org/downloads/
3. Download and copy the non thread safe version of Zenddebugger.dll (from 5_2_x_nts_comp folder) into ext folder of PHP install directory.
4. Include the following at the end of PHP.ini file in the PHP install directory
[Zend]
zend_extension="C:/Program Files/PHP/ext/ZendDebugger.dll"
zend_debugger.allow_hosts="localhost,127.0.0.1"
zend_debugger.expose_remotely=always
zend_debugger.connector_port=9009
5. Now open Eclipse and select Windows -> Preferences
6. On the preferences window select Debug under PHP. In the Default settings, select "Zend Debugger" from the dropdown and click on Configure link and enter 9009 next to Zend Debugger for the port. Next select the PHP servers link and enter the URL of the PHP web application (eg. http://localhost).

Tuesday, January 26, 2010

SPGridView and "Multiple Lines of Text" type in SharePoint.

To remove the div tag from being displayed in SPGridView when displaying data from "Multiple Lines of Text" column type, set the HtmlEncode property of the BoundField to false.

BoundField boundfield = new BoundField();
boundfield.HeaderText = "Description";
boundfield.DataField = "Description";
boundfield.SortExpression = "Description";
boundfield.HtmlEncode = false;

m_GridView.Columns.Add(boundfield);

Thursday, November 19, 2009

Windows 2008 on HP ProLiant DL380 G3 hangs after loading crcdisk.sys

Couple of days back I decided to upgrade my ProLiant DL380 G3 (about 3 or 4 years old) server to Windows 2oo8 from Windows 2003.

First issue was this server did not have a DVD drive, so I copied the bits to the local data disk and started the install. The install went fine without any issues. My next mega issue was, when the server restarted after the install it just hung while loading Windows. Next, I tried to restart it in safe mode. This showed me that it froze after loading crcdisk.sys.

Googling for information led me to a HP support forum which said that Windows 2008 server is not supported on DL380 G3 models. On the same thread someone had mentioned that the latest SmartStart tool allows you to install Windows 2008 server on DL380 G3 models.

My next stop was HP's support site to download the software. I select my server model and for the operating system I selected Windows Server 2003 and downloaded HP SmartStart CD x32 version 8.25. Used the CD made from the downloaded ISO image to restart the server.

Using SmartStart I was able to select Windows 2008 as the operating system and it also allowed me to install it from a USB drive directly using the ISO image. After a few minutes the server was up and running. There is no option to upgrade using SmartStart, so I ended up deleting the system partition and recreating it again. Which means all your data is lost, lucky me I had my data in a separate partition.

Thursday, November 05, 2009

Organization Hierarchy SharePoint web part.

Organization hierarchy web part shown on the profiles page of SharePoint My Site is defined in the person.aspx page of the SPSMSITEHOST site template (12 hive\TEMPLATE\SiteTemplates).
<SPSWC:ProfileManages FrameType="None" id="ProfileManages" runat="server" />
in person.aspx is the line which renders the organization hierarchy web part. This is defined in "Microsoft.SharePoint.Portal" assembly and the namespace is "Microsoft.SharePoint.Portal.WebControls".


Friday, June 12, 2009

Changing Silverlight player skin for Podcast Kit for SharePoint (PKS).

Here are the steps to change the skin for the Silverlight player in PKS:
1. Choose Site Actions->View All Site Content.
2. Select "Style Library" under "Document Libraries".
3. In Style Library navigate to PodcastingKit -> SLPlayerSkins. Professional.xaml file is the default skin applied.
4. Upload your skin to this library.
5. In Style Library select "XSL Style Sheets" folder.
6. Search for professional.xaml in PKSDetailItem.xsl and change it to the xaml file uploaded in SLPlayerSkins folder in step 3.

If you have Expression Encoder 2 installed, Check "C:\Program Files\Microsoft Expression\Encoder 2\Templates\en" directory for some skins provided by encoder. 

Tuesday, May 19, 2009

SharePoint Event handlers and Windows forms/Console application.

Couple of days back I was working on a windows forms application to add list items using the SharePoint object model. This list had ItemsAdded event handler registered to it using a feature. I noticed that while adding items programatically the event handler was not getting fired, the same worked fine if the items were added using the standard SharePoint interface.

My event handler was making use of some appSettings parameters. These appSettings parameters were included in the web.config while activating the feature for the event handler. It turned out that event handlers are called in the same context as the items being added. The solution was to add the appSettings parameters in the windows forms/ console applications configuration file. After doing so, the event handlers worked when adding items using the windows forms application.

Friday, April 04, 2008

Creating a WSS 3.0 Solution package from Reporting Services Web Part package

You can use Reporting Services SharePoint 2.0 Web Parts in WSS 2.0 and WSS 3.0 to access report server content on a SharePoint site from a native mode SQL Server 2005 report server or from a SQL Server 2000 Reporting Services report server.

There are two web parts as part of the Reporting Services Web Part. They are
  • Report Explorer – This allows you to connect to Report Manager on the report server computer. You can browse available reports on a report server and subscribe to individual reports.
  • Report Viewer – This allows you to display a report, it provides a toolbar that you can use to navigate pages, search for content, or export the report.
The Report Services (RS) Web Parts was introduced in SQL Server 2000 Reporting Services Service Pack 2 (SP2) and continue to be available in current releases of SQL Server. These Web Parts are provided as a Web Part package and is installed with SQL Server Reporting Services. You can install the RS Web Parts by running the STSADM.EXE using the following syntax (assuming you have installed the web parts in the default location)

STSADM.EXE -o addwppack -filename "C:\ Program Files\Microsoft SQL Server\90\Tools\Reporting Services\SharePoint\RSWebParts.cab" -globalinstall

For the web parts to work properly you have to install it on all the Web Front End (WFE) servers. This is a time consuming task if you have a large farm. Below, I will describe a step by step procedure to create a solution out of the web part package. I will use WSPBuilder, a SharePoint Solution Package creation tool for WSS 3.0 and MOSS 2007.

Steps to Create the Solution Package

1. Download the WSPBuilder application and extract to c:\WSPBuilder folder. Update the System “PATH” environment variable to include this directory.

2. Open the RSWebParts.cab using winzip.exe and extract the contents of the cab file to folder c:\RSWebPartsPkg. The contents of the cab file are shown in Figure 1.

Figure 1: RS Web part package cab file contents

3. Create a directory c:\RSWebParts and create the following structure as shown in Figure 2 under it.

Figure 2: Directory structure needed for WSPBuilder to create the solution package.

4. Copy the contents of directories de, es, fr, it, ja, ko, zh-chs and zh-cht from c:\ RSWebPartsPkg to c:\RSWebParts\80\resources directory.

5. Copy SPExplore.dwp and SPViewer.dwp files from c:\ RSWebPartsPkg to c:\RSWebParts\80\wpcatalog directory.

6. Copy report_explorer.gif and report_viewer.gif file from c:\ RSWebPartsPkg to c:\RSWebParts\80\wpresources\RSWebParts directory.

7. Copy RSWebParts.dll file from c:\ RSWebPartsPkg to c:\RSWebParts\GAC directory.

8. You need Microsoft.SharePoint.dll and Microsoft.SharePoint.Security.dll from WSS 2.0 version. Copy these dlls to c:\WSPBuilder\2003 directory. Without these files you will not be able to build the solution package.

9. Now open up a command prompt and change directory to c:\RSWebParts directory.

10. Execute the following command from the command prompt to create the solution package. See Figure 3.
WSPBuilder.exe -DllReferencePath c:\WSPBuilder\2003

Figure 3: Run WSPBuilder to create the RS Web Parts Solution Package

Installing the Solution Package

Following are the steps to install the RSWebParts solution package.

1. On the computer that has the installation of the WSS 3.0 or MOSS 2007, open a Command Prompt window and navigate to the folder C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN.

2. Add the RSWebParts.wsp solution the SharePoint farm using the following command
STSADM -o addsolution -filename RSWebParts.wsp

3. Next deploy the added solution using the following command
STSADM -o deploysolution -name RSWebParts.wsp -allcontenturls -immediate –allowgacdeployment

The Web Parts are now deployed on all the WFEs and are ready to be used.

Tuesday, March 04, 2008

Installing Language Packs for Office SharePoint Server 2007

Language packs enables Administrators of sites and site collections to create sites and site collections using different languages other than the install language. The language packs needs to be installed on all the web front-end servers in a farm. My suggestion would be to install the language packs on all the servers on the farm. So that if you need to convert an application server into a web front end server, you can do it with minimum effort.
Language packs are available for the following languages:
· Arabic
· Bulgarian
· Catalan
· Chinese (Simplified)
· Chinese (Traditional)
· Croatian
· Czech
· Danish
· Dutch
· English
· Estonian
· Finnish
· French
· German
· Greek
· Hebrew
· Hindi
· Hungarian
· Italian
· Japanese
· Korean
· Latvian
· Lithuanian
· Norwegian (BokmÃ¥l)
· Polish
· Portuguese (Brazil)
· Portuguese (Portugal)
· Romanian
· Russian
· Serbian (Latin)
· Slovak
· Slovenian
· Spanish
· Swedish
· Thai
· Turkish
· Ukrainian
Before you install language packs on your front-end Web servers, you must do the following:
· Install the necessary language files on your front-end Web servers.
· Install Office SharePoint Server 2007 on each of your front-end Web servers.
· Run the SharePoint Products and Technologies Configuration Wizard on each of your front-end Web servers.
Most language files are installed by default on the Microsoft Windows Server 2003 operating system. However, you must install supplemental language files for East Asian languages and languages that use complex script or require right-to-left orientations. Below are the steps to install the supplemental language support.

Installing Supplemental language support
Supplemental language support for complex script and right-to-left languages needs to be installed if you are installing the language pack for the following languages:
· Arabic
· Armenian
· Georgian
· Hebrew
· Indic
· Thai
· Vietnamese
Supplemental language support for East Asian languages needs to be installed if you are installing the language pack for the following languages:
· Chinese
· Japanese
· Korean
Following are the procedures to install supplemental language support on Windows 2003 server for
· Complex script and right-to-left languages
· East Asian languages

1. Go to Control Panel from the Start menu
2. Double click on Regional and Language Options in the control panel

3. Select the Languages tab in the Regional and Language Options window


4. Under Supplemental language support, Select the appropriate check boxes against :
· Install files for complex script and right-to-left languages
· Install files for East Asian languages

5. Click the OK button.
You will be prompted to insert the Windows 2003 install CD.
After installing the files, restart the server when prompted.


Downloading and installing the language pack
You download the language packs using the following URLs
http://www.microsoft.com/downloads/details.aspx?familyid=318D8562-58BD-4329-B1F6-F1941A38BC7F&displaylang=en (SharePoint Server 2007 x64 bit)
http://www.microsoft.com/downloads/details.aspx?familyid=2447426b-8689-4768-bff0-cbb511599a45&displaylang=en&tm (SharePoint Server 2007 x32 bit)

In the download page select the appropriate language from the drop-down and click on the change button. After the page refreshes, click on the Download button to get the language pack.
Once the download is complete use a tool like ISOBuster to extract the contents. Once extracted, click on setup.exe to install the language pack after accepting the license agreement.
After completing the language pack setup you must rerun the SharePoint Products and Technologies Configuration wizard using the default settings. If you do not run the SharePoint Products and Technologies Configuration Wizard after you install a language pack, the language pack will not be installed properly.


Once the download is complete use a tool like ISOBuster to extract the contents. Once extracted, click on setup.exe to install the language pack after accepting the license agreement.After completing the language pack setup you must rerun the SharePoint Products and Technologies Configuration wizard using the default settings. If you do not run the SharePoint Products and Technologies Configuration Wizard after you install a language pack, the language pack will not be installed properly.

Creating a Site collection using the installed language pack
1. In Central Administration click on Create Site Collection link in the Application Management tab.In the create site collection page go to Template Selection section and select a language from the drop-down.



3. Once you select the language, the template names and description in the Template selection section will be displayed in the selected language. Select the template to use for the site collection and click ok.


4. The new site collection will be rendered using the selected language.

Friday, February 29, 2008

How to Enumerate the Shared Service Providers using SharePoint Object Model.

SharePoint Object Model does not expose the SharedResourceProviders collection as a public property. It is a non-public member of the ServerFarm object.

This said, we can still access the SharedResourceProviders property using the magic of "reflection". Below is the code to enumerate the Shared service propviders.

using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;

using Microsoft.SharePoint;
using Microsoft.SharePoint.Administration;
using Microsoft.Office.Server;

namespace Velavan.EnumSSPs
{
class Program
{
static void Main(string[] args)
{
EnumSharedServiceProviders();
}

private static void EnumSharedServiceProviders()
{
//Get the default server context
ServerContext sc = ServerContext.Default;

//Use reflection to get the m_ServerFarm Property
object serverFarm = sc.GetType().GetField("m_ServerFarm", BindingFlags.Instance BindingFlags.NonPublic).GetValue(sc);

//Use reflection to get the ShareResourceProviders collection
object sharedResourceProviders = serverFarm.GetType().GetProperty("SharedResourceProviders").GetValue(serverFarm, null);

//Enumerate all Shared Service providers
foreach (object sharedResourceProvider in sharedResourceProviders as IEnumerable)
{
Console.WriteLine("SSP - " +
sharedResourceProvider.GetType().GetProperty("Name").GetValue(sharedResourceProvider, null) as string);
}
}
}
}


make sure you add the references to
Microsoft.Office.Server.dll and
Microsoft.SharePoint.dll

Friday, June 15, 2007

Conversion from ASP.NET 1.1 to ASP.NET 2.0

ERROR
It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level. This error can be caused by a virtual directory not being configured as an application in IIS

Solution
Remove web.config from the backup folder created by Visual Studio.

Changing the Configuration database server in MOSS 2007

To change the configration database server in MOSS 2007 do the following
1. Shutdown the servers in the farm
2. Copy all the configuration database to the new database server
3. Turn on the servers and execute stsadm -o renameserver -olservername -newservername
4. You should reboot the server
5. Execute these steps on all the servers in the farm

Thursday, March 30, 2006

Parsing HTML.

In my recent project, I had a requirement to parse HTML documents. I was debating between using the web browser control which gives the HTML as a DOM and HttpWebRequest where I had to do all the parsing. A quick search on google took me to Html Agility Pack.

This is a HTML parser that allows you to parse "out of the web" HTML files and creates a DOM. This supports plain XPATH or XSLT.

Difference between Directory.GetFiles and windows explorer sorting numeric files.

The .NET Sytem.IO.Directory.GetFiles class returns the files sorted in alphabetic order whereas Windows Explorer sorts them in numeric order. For e.g








In Directory.GetFiles In Explorer
04.html 1.html
040.html 3.html
05.html 04.html
1.html 05.html
10.html 10.html
3.html 040.html

If you have access to the source then you can pass the string array returned from Directory.GetFiles to Array's Sort(Array, IComparer) method to sort it in numeric order.

If you do not have access to the source then you can modify the registry as below for explorer to sort using the alphabetic order. Restart explorer for the changes to take effect.

For current user:[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer]

For the System:
[HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer]

Value Name: NoStrCmpLogical
Type: REG_DWORD
Value:1

Disclaimer: Modifying the registry can cause serious problems that may require you to reinstall your operating system. Use the information provided at your own risk.

Tuesday, November 22, 2005

Hidden MessageBox and VSTO

When trying to display a Message box from VSTO code, the message box is some times hidden in the background. MessageBox's Show method takes a "owner" parameter of type IWin32Window, this makes the Message box to be displayed in front of the IWin32Window passed. Below is a code snippet from gotdotnet site to get the IWin32Window of the foreground window.


// Stephen Toub
// stoub@microsoft.com
//
// ActiveWindow.cs v1.0.0
// 8/28/02
//
// Implements IWin32Window where Handle returns the handle of the system's foreground window.
// Can be used with MessageBox to display the box in front of the active window, such as:
// MessageBox.Show(ActiveWindow.Active, "Hello, World!");
using System;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace Toub.Windows.Forms
{
/// Used to get an IWin32Window for the active window.
public class ActiveWindow : IWin32Window
{
#region Private Members
/// Static instance to use for factory pattern.
private static ActiveWindow _window = new ActiveWindow();
#endregion
#region Construction
/// Prevent external instantiation.
private ActiveWindow() {}
#endregion
#region Public Properties
/// Gets an IWin32Window for the active window.
public static IWin32Window Active { get { return _window; } }
#endregion
#region Private Functions
/// Finds the frontmost window using the Win32 API.
[DllImport("user32.dll")]
private static extern int GetForegroundWindow();
/// Gets a handle to the active window.
System.IntPtr IWin32Window.Handle
{
get { return new System.IntPtr(GetForegroundWindow()); }
}
#endregion
}
}

Tuesday, November 08, 2005

How to Retrieve XML data from MS Word form fields using VSTO.

MS word has this cool feature where you can attach an XML schema to the document and tag the form fields with XML elements in the schema. When you save the document as XML, the form field values are stored as XML data. Unfortunately saving XML data does not work with Check box and Drop down form fields. So, if you need to save the data from Check box and Drop down form fields you have to walk through all the XML nodes and retrive the data. Below is a C# code snippet to walk through the XML nodes and write it as XML.


private string BuildWordDocumentXmlData(XMLNode xmlNode)
{
object oRef = 1;
object missing = Missing.Value;
Range range;
StringBuilder xmlString = new StringBuilder();
xmlString.Append("");
if(!xmlNode.HasChildNodes)
{
xmlString.Append("<" + xmlNode.BaseName + ">");
range = xmlNode.Range;
if (range.FormFields.Count > 0)
{
FormField formField = range.FormFields.get_Item(ref oRef);
if (formField.Type == WdFieldType.wdFieldFormCheckBox)
{
if (formField.Result.CompareTo("1") == 0)
{
xmlString.Append("true");
}
else
{
xmlString.Append("false");
}
}
else if (formField.Type == WdFieldType.wdFieldFormTextInput)
{
if (formField.Result != null)
{
xmlString.Append(formField.Result);
}
}
}
else
{
xmlString.Append(xmlNode.Text);
}
xmlString.Append("");
}
else
{
string returnString;
xmlString.Append("<" + xmlNode.BaseName + ">\n");
foreach(XMLNode childXmlNode in xmlNode.ChildNodes)
{
returnString = BuildWordDocumentXmlData(childXmlNode);
xmlString.Append(returnString + "\n");
}
xmlString.Append("");
}
return xmlString.ToString();
}
public void SaveWordDocumentXmlData(string xmlFileName)
{
Application.ScreenUpdating = false;
string xml;
try
{
xml = BuildWordDocumentXmlData(ActiveDocument.XMLNodes[1]);
using (StreamWriter sw = new StreamWriter(xmlFileName))
{
sw.Write(xml);
}
}
catch(Exception exp)
{
Trace.WriteLine(exp.ToString());
}
Application.ScreenUpdating = true;
}

Friday, October 21, 2005

My 1st blog on Blogger.

This is my first blog here.