RSS Feed
Mar 2

LiquidSilver switches to Mercurial on CodePlex

Posted on Tuesday, March 2, 2010 in News, Software

As you may have noticed, CodePlex now supports Mercurial as the source control. Mercurial is a free and distributed version control system. It’s currently gaining a high momentum that big projects like Mozilla, OpenSolaris, OpenOffice.org, Symbian OS, and many others are now using it. Aside from CodePlex, other project hosting sites like Google Code, bitbucket, and SourceForge also offer Mercurial support.

Because DVCS has many advantages over traditional centralized VCS such as Subversion or CVS, I also decided to switch to Mercurial for managing the source code of LiquidSilver.

Setting Up Mercurial on CodePlex

If you’re starting a new project, CodePlex will give you the option to use Mercurial as your version control system. For existing projects, unfortunately, you cannot switch to Mercurial by yourself. Instead, if you are a project owner, you can contact CodePlex using the contact form and tell your intention to switch to Mercurial. Ensure that you’re logged in when doing this and mention your project name, user name, and the email address associated to your user name.

For me, it took less than 24 hours before CodePlex responded to my request and LiquidSilver had been migrated to Mercurial. All the versions and labels were intact and I could clone the repository successfully. Thanks, CodePlex.

Using Mercurial

If you are just starting and not familiar with Mercurial or any DVCS in general, it can be confusing at first since the concept is different. Fortunately, Joel Spolsky has composed a wonderful tutorial site called Hg Init that can very quickly and greatly help you understand DVCS or Mercurial in particular. I highly recommend you to visit it. You can also learn Mercurial from its official learning site or the book.

Although you can use Mercurial entirely from the command line interface, you may find it easier or more comfortable to use TortoiseHg that provides a friendly and familiar (if you have used TortoiseCVS or TortoiseSVN before) interface for Windows users.

Visual Studio users can benefit from VisualHG, a Visual Studio extension that can give you real-time visual status updates on your files from within the Visual Studio Solution Explorer window. VisualHG depends on TortoiseHg to execute the Mercurial commands.

Now, have fun with Mercurial.

Jul 8

SharePoint Bending: Remove “Send To” Context Menu Without Modifying Core.JS

Posted on Tuesday, July 8, 2008 in Programming, Software

This is becoming a pretty common requirement. Some people just don’t want the “Send To” menu appearing in the context menu of the document library. You can do it — customize the SharePoint context menu by — by simply making some modification in core.js as suggested by many.

But modifying SharePoint core files should not be done, because your modifications can be overwritten by future SharePoint updates. So here’s a little trick to remove the “Send To” context menu without modifying core.js:

  1. Go to the document’s view url, for example: http://example.com/Documents/Forms/AllItems.aspx.
  2. If it is a web part page, edit the page and add a Content Editor web part. Otherwise you need to edit that page in SharePoint Designer.
  3. Open the source editor (not the rich editor) for the Content Editor web part, or open the code view (not the design view) of that particular page in SharePoint Designer.
  4. Either inside the web part or the code view, insert the following script:


    <script type="text/javascript">
    AddSendSubMenu = function (m,ctx) {}
    </script>

That script will redefine the AddSendSubMenu() function with a new implementation. Since the function body is empty, it simply won’t display anything, thus the “Send To” context menu is removed from the context menu.

You can do this on some pages manually, or if you want to apply this to all pages, just insert the code to your master page.

Jun 20

WSS/SharePoint Extension 1.2 for Visual Studio 2008

Posted on Friday, June 20, 2008 in Programming, Software

Finally it’s out, get it while it’s hot.

Now you SharePoint developers no longer need to hesitate to upgrade to Visual Studio 2008 if you haven’t.

This will greatly help development of SharePoint-based solutions when you’re using Visual Studio 2008 by providing the following features:

Visual Studio 2008 Project Templates

  • Web Part
  • Team Site Definition
  • Blank Site Definition
  • List Definition
  • Empty SharePoint Project

Visual Studio 2008 Item Templates (items that can be added into an existing project)

  • Web Part
  • Custom Field
  • List Definition (with optional Event Receiver)
  • Content Type (with optional Event Receiver
  • Module
  • List Instance
  • List Event Handler
  • Template

SharePoint Solution Generator

  • This stand-alone program generates a Site Definition project from an existing SharePoint site. The program enables developers to use the browser and Microsoft Office SharePoint Designer to customize the content of their sites before creating code by using Visual Studio.

Installing the WSS/SharePoint extension on Windows XP/Vista

If you are using Windows XP/Vista and try to install the extension, it will display the following error:

The product can only be installed if Windows SharePoint Services 3.0 has been installed first.

Instead of replacing your OS with Windows 2003, launching a Virtual PC image preloaded with SharePoint, or trying to install SharePoint on Vista, you can simply create a registry entry to fool the extension installer as if you have installed WSS on your XP/Vista machine. Before following these simple steps, as with any registry modification, do so with caution at your own risk. You can create a registry backup if necessary.

Basically — under the HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Shared Tools\Web Server Extensions\12.0 registry key — you need to add the following string value: Sharepoint="Installed".

Here is the step-by-step instruction:

  1. Run regedit from command prompt or Start > Run.
  2. Navigate to HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Shared Tools\Web Server Extensions\12.0.
  3. If you cannot find the “12.0″ folder, right click on the Web Server Extensions, select New > Key from the popup menu, and enter 12.0 as the new key name.
  4. Right click the “12.0″ key/folder, select New > String Value from the popup menu, and enter Sharepoint as the name.
  5. Double click the newly created Sharepoint entry, and enter Installed as the value data.
  6. Now you can try to install the Sharepoint extension for VS 2008.

An easier way to do the above steps is to download the SharePointOnXP.reg file, extract, double click on the file. Then you can try to install the extension.

By the way, if you haven’t done so, you might also want to add SharePoint’s dlls to the GAC. Hence, Visual Studio won’t find troubles when compiling your SharePoint-based projects.

Jun 2

SharePoint Bending: Forefront Forbids Programmatically File Uploads

Posted on Monday, June 2, 2008 in Programming, Software

I had a custom page that needed to be deployed inside a MOSS 2007 site’s document library. The problem was, there were more than 100 sites in the site collection. Manually uploading the file was so time-consuming, so I decided to write a simple console application to upload the file to each site’s document library.

The application simply made use of the Microsoft.SharePoint.SPFileCollection.Add() method to upload the file programmatically to the desired document library. In my development environment, it worked flawlessly. So happily I went to the client and ran the application in the production server. Almost immediately, the application exited without any message. It’s strange because I made it to output the upload status as well as the exception message.

Then I tried to add a more verbose exception handling, by printing out the exception stack as well as the exception type, and I got this following output:

Exception class: Microsoft.SharePoint.SPException
Exception message:
Stack Trace:
at Microsoft.SharePoint.SPFileCollection.Add(String urlOfFile, Byte[] file, Boolean overwrite, String checkInComment, Boolean checkRequiredFields)
at Microsoft.SharePoint.SPFileCollection.Add(String urlOfFile, Byte[] file, Boolean overwrite)

See? No exception message. How the heck would I know what happened then? Well, at least I got the idea that the failure was at the Microsoft.SharePoint.SPFileCollection.Add() method execution. I ran the code under the administrator account, the same account used as the site’s administrator, so it shouldn’t be the account problem. I fired up the browser, tried to upload the file manually to the document library using the same administrator account, and it also worked. So definitely this was not a problem related to the permission.

After messing around with the site’s settings and permissions, rewrote my application’s code many times, as well as googled for solutions, I finally found out the real problem. It’s not the code or the permission problem. But it seemed that the production server had Microsoft Forefront Server Security installed. It was configured to scan for viruses on every file uploads and downloads.

So what I did to fix the issue is:

  • Open SharePoint Central Administration
  • Open the Operations tab
  • Click on the Antivirus link under the Security Configuration section
  • Turn off the Scan documents on upload setting

Then I could successfully executed my application to upload the file to every sites.

This is a mere workaround to resolve this problem temporarily. I still need to find a more proper solution so my application can work with Forefront.

Aug 7

Should LINQ End SubSonic (and Other DAL Tools)?

Posted on Tuesday, August 7, 2007 in Programming, Software

SubSonicFirst, I’d like to say that SubSonic is really really awesome. I just know SubSonic for three or four months, but I already created some new projects and converted some old ones with SubSonic. And they were commercial projects.

Compared to SubSonic, all other DAL tools look “awful”. I’ve been using plain old ADO.NET, NetTiers, NHibernate, and even created my own DAL tool. But once I use SubSonic, I suddenly have more time to date, play games, watch movies, and do other fun things.

Regarding LINQ, this stuff is simply great. It is not just yet another DAL tool. It even extends the language with querying capabilities, not just to DB but almost everything. I just had the chance to play with it yesterday—although I have read about it for a long time—, and I was very impressed. If only Microsoft had created it earlier.

Yes, LINQ currently only supports SQL Server, but this is really just a matter of time. Soon more providers will emerge surely.

Having the advantages of being provided out of the box with .NET Framework 3.5, the cool query keywords built-in the languages, as well as the capability to query beyond database, I think it will be extremely hard not to pick LINQ over other DAL tools.

So, for pure DAL tools out there, I guess this is the end. But for SubSonic, I don’t consider SubSonic is merely a DAL tool, but a great time saver.

The “convention over configuration” mantra that it brought from the sacred realm of Ruby on Rails simplifies many things. For example, SubSonic will know whether my tables have some auditing fields (i.e., CreatedOn, CreatedBy, ModifiedOn, ModifiedBy) and populate them automatically for me. It knows when to use soft or hard delete by checking if there is a Deleted or IsDeleted field in a table. Did I mention SubSonic has auto scaffolding and the useful utility classes (a.k.a. SubSonic Sugar)? All of them is really a great time saver.

SubSonic spoils me so much I hate to not being able to use it in my projects. I really hope that SubSonic can work hand in hand with LINQ to ease developer’s life much further. The combined strength of language level queries provided by LINQ and the “convention over configuration” mantra and utilities provided by SubSonic will certainly grant developers with a great power to finish projects better and faster.