The search service is not able to connect to the machine that hosts the administration component

January 24th, 2012 in SharePoint. No Comments ».

Another example of “when SharePoint goes wrong.” On a dev machine, the search service mysteriously stopped working. I can’t pinpoint what caused it, but SP1 and a CU were recently applied and these seem like good candidates for breaking things. When trying to admin the search service, you would see the following error:

The search service is not able to connect to the machine that hosts the administration component. Verify that the administration component ’{guid}′ in search application ‘Search Service Application’ is in a good state and try again.

…and trying to modify the topology of the search, resulted in a spurious error:

An unhandled exception occurred in the user interface.Exception Information: Exception has been thrown by the target of an invocation.

Something was clearly unhappy. Rather than waste too much time, the simplest solution seemed to be to delete the search application and recreate it, which I duly did, via Central Admin, verified that DBs and application pools disappeared and recreated the search application, using new names and credentials. Same error. I wasted spent some looking at permissions and the usual array of logs, events and other candidates, ran PSConfig and other upgrades, all to no avail.

I figured I could create the search application via Powershell. Why should this make a difference? No idea, but worth a shot. Then thankfully, I found that someone had already done it for me. And yes, this resolved the issues. I can’t explain why seeing as this script shouldn’t do anything that the GUI doesn’t do.

Script:

Read the rest of this entry »

Error formatting query, probably invalid parameters [SQLSTATE 42000] (Error 22050)

December 12th, 2011 in Databases. 1 Comment ».

I just tripped over this problem, and despite a fair amount of Googlage, I didn’t find anything that directly resolved my issue. I was trying to use dbMail in SQL Server 2008 to send an email on a schedule which included the results of a query. Doing this should be fairly straightforward, by executing the sp_send_dbmail stored procedure, which is in MSDB:

This query works fine in SSMS, but when run as a SQL Server Agent Job, it fails, with the error

Error formatting query, probably invalid parameters [SQLSTATE 42000] (Error 22050)

A few things need to happen to make this work:

1) The account that the task is running as (e.g., SQL Server Agent account) needs to be a member of MSDB. I also granted it rights on the Agent roles, and DBMailUser role, as well as Read, Insert, Connect, Execute, etc.
2) It will also need permissions on the database that you’re trying to connect to query.

I saw a lot of other hints on ways around this, like add a “USE DatabaseName” as part of the expression, but none worked. Here’s what got it working for me.

In the Agent Job setup, you have the option to specify which database to use. I instinctively set this to the database I wanted to query. But alas, this is not right. You need to set it to MSDB, and then update your query to include the @execute_query_database parameter:

After that, things should work.

Useful SharePoint script to restart SharePoint services and IIS

December 2nd, 2011 in SharePoint. No Comments ».

A SharePoint developer’s life is filled with many things, but one of the most common is the old faithful iisreset, coupled with a reset of the Timer Service and the Admin Service. When you’re working on timer jobs, it can get tedious quickly to have to  keep resetting things.

So I’m sharing a useful batch script I knocked together to do it for you. It will perform three functions – restart the SharePoint 2010 Timer Service, the SharePoint 2010 Administration Service and do an IISReset. It will prompt you if you want to do each of them, and if you don’t reply within 5 seconds automatically do it.

Simply save it as a .cmd file, and then create a shortcut to it, and put that shortcut on your start menu/quick launch. Restarts ahoy!

Enjoy.

@echo off
@echo Quick SharePoint services restart - from www.thorntontechnical.com
@echo Stopping Sharepoint services...

:P1
REM - SharePoint timer service
CHOICE /C:YN /M "Restart Timer Service?" %1 /T 5 /D Y

if ERRORLEVEL ==2 GOTO P2
if ERRORLEVEL ==1 GOTO A1
:A1
net stop "sharepoint 2010 timer"
net start "sharepoint 2010 timer"
:P2
REM - SharePoint timer service
CHOICE /C:YN /M "Restart Admin Service?" %1 /T 5 /D Y
if ERRORLEVEL ==2 GOTO P3
if ERRORLEVEL ==1 GOTO A2
:A2
net stop "sharepoint 2010 administration"
net start "sharepoint 2010 administration"
:P3
REM - reset IIS
CHOICE /C:YN /M "Reset IIS?" %1 /T 5 /D Y
if ERRORLEVEL ==2 GOTO END
if ERRORLEVEL ==1 GOTO A3
:A3
iisreset -restart -noforce
:END
echo Finished. Thanks. Have fun.

Configuring certificates and trust in SharePoint 2010 for accessing Exchange Web Services

November 9th, 2011 in Exchange Web Services, SharePoint. No Comments ».

Exchange is built on web services and as I posted about a while about accessing EWS from SharePoint can be pretty neat. There is a managed API to make your life even easier. However, one issue you may come across is actually getting SharePoint and Exchange to talk nicely to each other. This will walk you through some of the steps required to get things going.

Read the rest of this entry »

SharePoint 2010: The filename, directory name, or volume label syntax is incorrect

November 7th, 2011 in SharePoint. No Comments ».

This is a peculiar little bug. When creating a List Definition, you may encounter the following error when you try to deploy:

The filename, directory name or volume label syntax is incorrect.

It took a while to track the cause, seeing as a lot of info out there info out there relates to things to do with file systems, which in this case, obviously wasn’t the cause.

The bug for me was that I had created a List Definition and called it My.List.Definition – notice the multiple periods. I wanted it to match the namespaces that we were using. It turns out that the second period trips it up. When you create a List Definition with multiple periods, the List Definition only gets the first period, e.g., My.List, whereas the Elements.xml file for the List Definition still references My.List.Definition – hence it can’t deploy properly.

To fix, edit the Elements.xml file to match the List Definition name. However, I’ve experienced knock-on issues as a result of this, for example, instances of the List Definition fail to deploy. It seems more reliable to completely delete the List Definition and recreate it with at most one period in the name.