You may encounter the following error if you are trying to build a ASP.NET application or web service on a x64bit machine where Sharepoint is installed:
Error 1 Could not load file or assembly ‘Microsoft.SharePoint.Search, Version=22.214.171.124, Culture=neutral, PublicKeyToken=71e9bce111e9429c’ or one of its dependencies. The system cannot find the file specified. C:\Documents and Settings\robgruen\My Documents\Visual Studio 2005\WebSites\MyWebService\Web.Config
What happens is that the ASP.NET compiler is a 32bit process and tries to load 32 bit assemblies. Since you’re on a 64 bit box and the Sharepoint install NGENs it’s asseblies, there are only 64 bit assemblies available. This causes the compiler to not load the referenced assemblies (Microsoft.Sharepoint.*.dll) and causes the error shown even though the assemblies are in the GAC, bin folder, etc.
You can fix this problem by placing 32bit versions of the referenced assemblies in the bin folder of your web application. Unfortunately IL versions of the Sharepoint dlls do not ship with the Sharepoint SDK so you’ll have to find a 32 bit install of Sharepoint where you can grab the dlls from.