Archive

Convert an SPListItemCollection to an IEnumerable

No Comments

In one of my last project I make a function to accept an IEnumerable<T> as parameter. I normally used this function with PublishingPageCollection. This collection inherits from QueryBasedCollection<PublishingPage> and so it is a IEnumerable. Unfortunately the SPListItemCollection it is not.

I didn’t want to change my method and I didn’t want to create an overload only for the type of parameters. Then…I remembered that LINQ is my friend :)
You can directly convert an SPListItemCollection. Below an example…hope can help you…

using (SPWeb web = SPContext.Current.Site.OpenWeb("myweb"))
{
       return web.Lists["MyList"].Items.Cast<SPListItem>().Select(item => item);
}

SharePoint 2010: error crawling People

No Comments

Today I figured out a funny problem. When you know it’s easy, but I lost an hour to understand what the hell was going on.
In my SharePoint 2010 Farm everything was going fine…I installed and configured the User Profile Synchronization, the MySite was well configured in a specific Web Application. I needed to search people so I went to the Central Administration > Management Application >  Service Application > Search Service Application and start the Full Crawl.

Unfortunately once ended the Full Crawl I had this error on the log:

sps3://SERVERNAME
Error in PortalCrawl Web Service

I started to search and really don’t understand why…In the ULS I found this error:

PortalCrawl.GetSite(): System.NullReferenceException:
Object reference not set to an instance of an object.
at Microsoft.SharePoint.Portal.Search.
PortalCrawl.PortalCrawl.GetSite(_PortalSite& sSite).

and I finally got it. The default site in SharePoint http://SERVERNAME on port 80 must be created and a site collection must be too, otherwise you’ll problem will be not solved. Honestly in my configuration I never use the default web site, because I use personalized DNS, but since today I’ll do always :)
Now my scope “People” is well done:

 

Hope this can help,

M.

 

Ideal configuration for SharePoint 2010 dev environement

1 Comment

In my experience when you develop an application in SharePoint 2010 you should have environment the most close possible to the client configuration. This means that the classical URL http://mysrv:4354 or http://mysrv:3145/sites/mycoll are not the best configuration you can have.

Beside that even to work with a local user is really not the best…you can develop something that locally works like a charm, but when you’ll install into the client farm you’ll be quite surprised.
I would like so to share my configuration with you and I hope you can find something interesting in that. Of course, I’m not the “inventor” of this configuration, but it’s just my “best practice”.

  1. VM Ware machine with Win2008 R2 installed with the scope of Primary Domain Controller, with 512 MB  of RAM
  2. VM Ware machine with Win2008 R2, SQL Server 2008 R2 and SharePoint 2010 installed as a Single Server Farm , with 4096 GB of RAM

 

Primary Domain Controller

The primary domain controller will be an “easy” machine, configured as below, where the DNS server is installed and configured.
To install the DNS server, please take a look to this link

Once you have installed the DOMAIN, please create the following users:

  • SPAdmin: he will be the farm administrator of you SharePoint installation
  • AppPool: he will run the application pool of your web applications
  • DBAmin: he will be the administrator of the database server
  • Guest1, Guest2 and Guest3: you can use these users to configure different users of your site collections. It is very important you make your test with different roles.

Forward Lookup Zone

As I said above, for my experience you should have, as host header a real configuration and the OOB URL of SharePoint they aren’t. It’s not so hard, by the way, to have this feature.

  • Open your DNS manager
  • Open the item Forward Lookup Zone and open you domain item too
  • In order to have your items well organized create a new domain named SHAREPOINT. You’ll save here your host headers. When you create a new host header you’ll associate the name with an IP address you’ll set in the SharePoint machine.

SharePoint Server

Once you installed your new virtual machine with Windows 2008 R2 and SqlServer 2008 you have to add to the domain. In order to achieve this goal you have to add a new Network Adapter and configure as HOST ONLY.

When you have your new network adapter you’ll configure the IPV4 in order that your Active Directory machine will be the DNS server. You’ll add, after that, all the IP address you choose for the host headers. (Click ADVANCE in the main windows of IPV4).




After all these steps if you try to PING your host header by name (ex. das.sharepoint.sintax.local) you’ll obtain the response of your main SharePoint machine.

To install SharePoint I think is not necessary any specification. You’ll find on the Microsoft site all you need. My points are just when you’ll configure your new web application. We created a DNS specific for one web application: this means we can use our web application in the 80 port. See the image below and you’re done :)

In my experience this configuration can really help you to make your application with a real environment, most similar to the client configuration than the OOB SharePoint url and host header.

Blue Taste Theme created by Jabox