SharePoint 2010 Search: Internal server error exception: System.NullReferenceException

When we try to perform search on https://sharepoint10/_layouts/OSSSearchResults.aspx we get following error

Internal Server Exception

Correlation ID : 7b8967ae-1ff7-41bc-8ea4-5153ef9d1a6c

ULS Logs:

0x3DDC SharePoint Server Search Query fm9a Unexpected CoreResultsWebPart::OnInit: Exception initializing: System.NullReferenceException: Object reference not set to an instance of an object. at Microsoft.Office.Server.Search.WebControls.CoreResultsWebPart.SetPropertiesOnQueryReader() at Microsoft.Office.Server.Search.WebControls.CoreResultsWebPart.OnInit(EventArgs e) 7b8967ae-1ff7-41bc-8ea4-5153ef9d1a6c

03/09/2011 10:13:23.93 w3wp.exe (0x3BE0) 0x3DDC SharePoint Server Search Query g1j9 Exception Internal server error exception: System.NullReferenceException: Object reference not set to an instance of an object. at Microsoft.Office.Server.Search.WebControls.CoreResultsWebPart.SetPropertiesOnQueryReader() at Microsoft.Office.Server.Search.WebControls.CoreResultsWebPart.OnInit(EventArgs e) System.NullReferenceException: Object reference not set to an instance of an object. at Microsoft.Office.Server.Search.WebControls.CoreResultsWebPart.SetPropertiesOnQueryReader() at Microsoft.Office.Server.Search.WebControls.CoreResultsWebPart.OnInit(EventArgs e) 7b8967ae-1ff7-41bc-8ea4-5153ef9d1a6c


Check for following settings under Central Administration and Click System Settings on the left and select Manage Services on Server and found them to be started

SharePoint Server Search

Search Query and Site Settings Service

Check the Search Server WebParts feature was activated on https://sharepoint10 (Site Actions --> Site Settings --> Site Collection features)

Check the Alternate Access Mappings if you have multiple zones

Check the permissions for the “Documents and Settings\All Users\Application Data\Microsoft\Crypto\RSA\ Machine Keys” on the SharePoint Servers

Note: Everyone has Special Permissions

imageimageimageimage

 

Note: This can also happen if the hotfix https://support.microsoft.com/kb/976462 is not present on the server

This hotfix provides the following features for Windows Communication Foundation (WCF) in the Microsoft .NET Framework 3.5 Service Pack 1 (SP1) on a computer that is running Windows 7 or Windows Server 2008 R2. This hotfix is also a prerequisite for Microsoft Office SharePoint Server 2010.


We confirmed that KB976462 was not installed (Add Remove programs --> View Installed updates).

An attempt to install the hotfix from https://code.msdn.microsoft.com/KB976462 we got following error "The update is not applicable to your computer"

We tried removing the .net feature and re-installing it
Going to Server Manager --> Features --> Remove Features --> Uncheck (.Net Framework 3.5.1 features) and then complete the wizard
Note: This may require a restart
After the restart go to Server Manager --> Features --> Add Features --> Check (.Net Framework 3.5.1 features) and then complete the wizard and then tried installing the hotfix again https://code.msdn.microsoft.com/KB976462 however, that didn’t help.

Note: We discovered that we are running Microsoft Windows Server 2008 R2 SP1. It seems like package (KB976462) was included in Sp1 with build #. 7601.

We then compared the dll version located under (C:\Windows\Microsoft.Net\Framework64\v3.0) and found that the version was lower than expected.
Servicemonikersupport.dll (3.0.4506.4926) --> Service Pack 1
Servicemonikersupport.dll ( 3.0.4506.5000) --> Win 2008 RTM + https://support.microsoft.com/kb/976462

Workaround:

Open Control Panel --> Add\Remove Programs --> View installed Update and then Un-install Service pack for Microsoft Windows
Note: This may require a reboot.

Install https://support.microsoft.com/kb/976462


This issue can also happen if you get following error in the ULS Log

ULS log:

w3wp.exe (0x15D0) 0x2A40 SharePoint Foundation Claims Authentication fsq7 High Request for security token failed with exception: System.ServiceModel.ServerTooBusyException: The HTTP service located at https://localhost:32843/SecurityTokenServiceApplication/securitytoken.svc/actas is too busy. ---> System.Net.WebException: The remote server returned an error: (503) Server Unavailable.  

Cause:

Open IIS manager and then expand sites and then expand SharePoint Web Services SecurityTokenServiceApplication virtual directory would not be present.

Solution:

To provision the Security Token Service Application

1 .Open Command prompt (run as administrator)

2. Navigate to C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\bin

3. Execute:

stsadm -o provisionservice -action start -servicetype "Microsoft.SharePoint.Administration.Claims.SPSecurityTokenService, Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" -servicename SecurityTokenService

4. Perform an IISRESET /NoForce

If you navigate back to IIS Manager expand sites and then expand SharePoint Web Services SecurityTokenServiceApplication should be available.

Please Note: This was based on few cases which I worked on, if the above steps doesn’t resolve the issue I would suggest to open a ticket with Microsoft Support.