February, 2009

Refactoring: extract interface

Extract interface is one of the most common refactoring techniques. Motivation behindextract interface refactoring method is to avoid direct dependencies between classes. Instead of using classes in method calls we use interfaces so we can also use subclasses of those classes we used before. Also we can create brand new classes that use follow these interfaces and we can use these classes instead of current ones.

SharePoint: creating SharePoint accounts for Live ID users

Couple of weeks ago I started adding Windows Live ID authentication support to SharePoint. I used Community Kit for SharePoint and I also made here some notes about it. There was one problem – although user is authenticated there is no SharePoint user and it is not possible assign it to any roles. Here is some advices how to create SharePoint user account when new user is registered after logging in using Live ID.

ASP.NET MVC: Ignore requests to favicon.ico

One problem I faced when writing my example pet portal on ASP.NET MVC was Google Chrome’s request to favicon.ico that doesn’t exist. IE8 that I use (8.0.7000.0) doesn’t make these blind requests to discover that favicon.ico is not there. Solution to my problem was very simple.

Writing messages to ULS (Unified Logging System)

If you want to make your SharePoint solution more SharePoint way you can write your tracing, debug and error messages to SharePoint log. Easiest way to do it is to write logger by yourself. Btw, SharePoint has class called ULS to write messages to logs but this class is internal and we cannot use it. But it is there.

SharePoint: Access denied error when adding new page to page library

On one of my servers I detected very weird error. There are authenticated users who can add content to some page libraries and modify pages they have made. One day suddenly they were not able to add pages to page library anymore because of Access Denied error.

Starting with ASP.NET MVC

About a week ago I started learning ASP.NET MVC framework. It is pretty cool entertainment for cold winter nights as I found out. Here you can find how I got started and what resources I used.

Show your Twitter log in SharePoint

About year ago I wrote how to display blog feeds in SharePoint sites using XML Web Part. Today is Twitter very popular and we can use XML Web Part to render Twitter feeds. To see how to configure XML Web Part check out blog feeds entry referred above.

Please help – Visual Studio SharePoint development environment is very slow

I run SharePoint development environment on virtual machine. Virtual machine has 2GB RAM and 30GB disk space. Also I have no complaints over processor (I can run here two usual ASP.NET development virtual machines parallel). All other Visual Studio projects are working well except those that use VSeWSS 1.2.

Debugging SharePoint solutions using Visual Studio

Debugging SharePoint solutions with Visual Studio on local machine is pretty easy. Although you can find articles about how to deploy your PDB files to global assembly cache etc it is more simpler than that. Just follow the steps below. Btw you can click on images if you want to see them on original size.

SPListItemCollection.GetDataTable() – be careful

Seems like I am stuck in ADODB days a little bit and I still expect that query with no results returns at least some meta data. Or at least my code gets no bombed by null references.SPListItemCollection has GetDataTable() method that returns items collection as ADO.NETDataTable objects. Be careful when using this method – if your items collection is empty then this method returns null.

Creating cross-site lookup field in SharePoint

Cross-site lookup field is something we need almost every project that is not very small. There is no good OOTB solution but we can use field by Toby Bierman. This kind of field is easy to create because SPFieldLookup is cross-site by its nature. Basically you ave to perform the following steps.

SharePoint and Windows Live Authentication

In one of my SharePoint projects I had to implement authentication using Windows Live ID. I’m too lazy to code all this stuff from zero if it is possible to find already working solutions. I found out that Community Kit for SharePoint has something for me – Windows Live Authentication 1.0. After some hacking everything started to work.

UserProfileManager.UserExists and “Operation is not valid due to the current state of the object”

I have clean install of MOSS 2007 and I have one .aspx page that makes some request to SSP. All the code in this page is running in elevated permissions and I decide programmatically what kind of content this page shows to visitor. When I check if user profile exists I get the following error message: Operation is not valid due to the current state of the object.

Visual Studio add-in: CopySourceAsHTML

When I started with this blog I needed some tool to copy code snippets from Visual Studio to Windows Live Writer so I get formatted code. There is cool online code highlighter called GeSHi, but I wanted my code to look like in Visual Studio editor. After some searching I found Visual Studio add-in CopySourceAsHTML.

Some notes about custom C# application and Exchange Server 2003 integration

Custom C# application and Exchange Server 2003 integration over WebDAV was one of the tasks I lately worked on. I made posting about how to log on to Outlook Web Access when FBA is used but I didn’t mentioned that I had to read data from Exchange public folders. There are some stuff that may drive you nuts but there are also some tricks to use to get everything work as expected.

Refactoring: Rename method

One of the simplest refactoring methods is called Rename method. There are many reasons why one may want to change the name of some method. I think that main reason to rename a method is to give it a name that describes better what method is supposed to do.

Apache, IIS and 502 proxy error

I have some servers in my network. There is one public Apache server that proxies requests to these servers. These servers are not directly visible from internet. Some of these servers run IIS and ASP.NET web applications. When accessing these servers through internet then sometimes Apache reports a problem: 502 proxy error.

SharePoint: temporary solution for GetCustomProperty and SetCustomProperty errors

Another day, another kinky problem with SharePoint. This time I struggled with custom properties of my custom field. I tried out different code samples to make GetCustomProperty and SetCustomProperty to work but no luck at all – nothing worked for me. There was no errors when adding field to list or changing field properties but custom properties were never saved.