Wednesday, November 23, 2011

Chrome Query

When creating websites I often use jQuery's .data() function to add data to elements. When debugging my web site I sometimes want to know what data is attached to an element.
For Google Chrome there is a extension Chrome Query which allows me to view jQuery data (it’s still an experimental extension).
Chrome Query:Extends the Developer Tools, adding a sidebar that displays the jQuery data associated with the selected DOM element.

To install the Chrome Query extension:
  1. First enable the experimental API support in Chrome.  Start Chrome, Go to chrome://flags, find "Experimental Extension APIs", click its "Enable" link, and restart Chrome. From now on, unless you return to that page and disable experimental APIs, you'll be able to run extensions that use experimental APIs.
  2. Extract the package
  3. Click on Load unpacked extension
  4. Select the folder where you extracted the extension and click OK.

Monday, October 31, 2011

CheckAsm

If you know and use Dependency Walker (depends.exe), you will probably need CheckAsm too. CheckAsm is just "depends for .NET".
CheckAsm is an assembly dependency viewer. It shows all .NET assembly references of any .NET assembly. This means you can always find what references are incorrect, which assemblies are missing, and why your application can not start.

Tuesday, September 13, 2011

smtp4dev

Some of my colleagues pointed me at a little “SMTP Server”, called smtp4dev. It’s an SMTP server that listens on your local machine and captures all messages, which you can easily view and open. Very handy when you send email message in your application and you want to see how the message looks, without the requirement to install a real SMTP Server.


Other SMTP servers you could consider to use:
  1. Squirrelmail
  2. SurgeMail

Uninstall MSI which fails to uninstall

Uninstall MSI which fails to uninstall sounds like strange, but it is possible.

Sometimes when you try to uninstall a msi the msi fails to uninstall with an error message like, the screenshot below.
This could be caused by a custom action which fails to execute.

To indicate if this is really the problem run the uninstall with the following command:

C:\Temp\ Setup.msi /log c:\uninstall.log

(if you don’t know where the msi is located, search the registry on the product name and you will find it. You should search until you find a match in “HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData” like “HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Products\B2729D7731537264797FB846DDDCF225\InstallProperties”)

The log file should now contain something like:
(The black line containing the name of the custom action). To make it possible to uninstall the product perform the following steps:
  1. Locate the msi in the C:\Windows\Installer\ (search in the registry on the product name and you will find it).
  2. Make a backup of the msi (you never know what happens)
  3. Open the original msi file in Orca.
  4.  Locate the CustomAction table.
  5.  Select the CustomAction which cause the problem.
  6.  Delete the selected custom action.
  7. Save the msi and close Orca.

Thursday, January 13, 2011

HowTo - SharePoint - Build a WSP for an Index Server

I created a solution for SharePoint which must be installed on all the Index Servers in a Farm. So I build a WSP solution with WSPBuilder and I thought that would be it. Because had some code in the feature activate of one of my feature, I thought let’s test the wsp in an environment where my Index Server is a dedicated Index Server (so not a Frontend Server).


To my astonishment, I found out that the WSP was only deployed to all the Frontend servers in my Farm but not to the Index Server :(

Cause

A wsp contains a manifest.xml, which looks like this:

 
 
 
 
 
 
 
 
 


 
When you build a WSP using WSPBuilder, by default the Solution element does not contain a DeploymentServerType attribute, which is the cause of the problem. The DeploymentServerType has the following description:

DeploymentServerType : Optional. Default=WebFrontEnd. This attribute indicates the target of your solution to either a web front end server (WebFrontEnd) or an application server (ApplicationServer).

Solution


Make sure the DeploymentServerType is specified in the manifest.xml. To accomplish this, you need to edit the WSPBuilder.exe.config (in my case in the folder C:\Program Files\WSPTools\WSPBuilderExtensions), and add the attribute DeploymentServerType.


 
 
 

Tuesday, January 11, 2011

HowTo - SharePoint - Get a list of SSPs in code

Ever wanted to get a list of all the Shared Services Provider (SSP) in a SharePoint Farm, for example to retrieve all the search service instances in a Farm?


To accomplish this, we need to walk through all the web application and determine if the web application is a SSP web application. We can do this by validating if the web application contains a property called “Microsoft.Office.Server.SharedResourceProvider”. The property “” contains a property “AdministrationSiteId”, which is the id of the SSP Administrator Site.

Remark: in most situation we will get two web applications, for a single SSP, with the “Microsoft.Office.Server.SharedResourceProvider” property. This because in most situation we have a Search web application and a MySite web application for a SSP.

The code will look like this:

 private StringCollection GetAdminSiteIDs(SPFarm farm)
{
   StringCollection colAdminSites=new StringCollection();
   SPWebService webService = farm.Services.GetValue();
   foreach (SPWebApplication webApp in webService.WebApplications)
   {
      //Check if the web app contains a property Microsoft.Office.Server.SharedResourceProvider,
      //which indicates it's a SharedResourceProvider.
      if (webApp.Properties.ContainsKey("Microsoft.Office.Server.SharedResourceProvider"))
         {
            object ssp = webApp.Properties["Microsoft.Office.Server.SharedResourceProvider"];
            
            //Get the guid of the Administration Site
            Guid sspGuid = (Guid)ssp.GetType().GetProperty("AdministrationSiteId").GetValue(ssp, null);

            //Check if the site is already processed, because for each SSP, we get two SharedResourceProvider
            //one Search and one MySite.
            if (!colAdminSites.Contains(sspGuid.ToString()))
            { 
               colAdminSites.Add(sspGuid.ToString());
            }
         }
   }
   return colAdminSites;
}