Wednesday, May 29, 2013

How to repair "Distributed Cache" service in SharePoint 2013

I got the error below when trying to start up service "Distributed Cache".  After quite a while investigation, I believe it's corrupted.

Call to OpenService(...,SERVICE_START | SERVICE_QUERY_STATUS | SERVICE_STOP | SERVICE_PAUSE_CONTINUE) function to get handle to the service failed (0X424=1060)

What I need is to reinstall it in the farm.

Below is how I did it.

1. Uninstall the components "AppFabric 1.1 for Windows Server" and "Windows Fabric"



2. Reinstall SharePoint 2013 prerequisites.


3. Run SharePoint 2013 configuration wizard on all SharePoint servers

4. Remove and then add "Distributed Cache" service through PowerShell script on all Servers

Remove-SPDistributedCacheServiceInstance

Add-SPDistributedCacheServiceInstance

( In some cases, we might have to delete the service by GUID first )




5. Done.

People search returns 404 page not found - Sharepoint 2010

I got this error in a new web application.  Google leads me to here and here, but none of them fit my case. I had configured the "My Site Settings" in "Central Administration, User Profile Service Application", and the "Search settings" in "Site Collection Administration".

Then I noticed that the search centre site was a sub site of the root site collection, in the original web application. It looked strange. So I created a dedicated site collection based on "Enterprise Search Centre" template, and then reconfigured the relevant search settings.

BING! The problem was fixed.  :-)

Tuesday, May 28, 2013

Error: The specified module 'WorkflowManager' was not loaded because no valid module file was found in any module directory

All of sudden, on one of the development server, the "Workflow Manager PowerShell" stopped working.  When trying to start it, I got the error message below.

Import-Module : The specified module 'WorkflowManager' was not loaded because no valid module file was found in any module directory.
At C:\Program Files\Workflow Manager\1.0\Scripts\ImportWorkflowModule.ps1:20
char:1
+ Import-Module WorkflowManager
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ResourceUnavailable: (WorkflowManager:String) [Import-Module], FileNotFoundException
    + FullyQualifiedErrorId : Modules_ModuleNotFound,Microsoft.PowerShell.Comm
   ands.ImportModuleCommand

Lucky I have another workflow server which works well. It turns out the "AppFabric server" or "Workflow Manager 1.0" installation & uninstallation caused this issue. The window environment variable "PSModulePath" was changed from

C:\Windows\system32\WindowsPowerShell\v1.0\Modules\;C:\Program Files (x86)\Microsoft SQL Server\110\Tools\PowerShell\Modules\;C:\Program Files\Service Bus\1.0\;C:\Program Files\Workflow Manager\1.0

to

C:\Windows\system32\WindowsPowerShell\v1.0\Modules\;C:\Program Files (x86)\Microsoft SQL Server\110\Tools\PowerShell\Modules\;C:\Program Files\Service Bus\1.0\;C:\Program Files\Workflow Manager\1.0"

After removing the double quote at the end of the environment variable value, "Workflow Manager PowerShell" is recovered!



PS: if got error message below during the installation of AppFabric server, possibly we just need to do the same change to window environment variable "PSModulePath".

Call to OpenService(...,SERVICE_START | SERVICE_QUERY_STATUS | SERVICE_STOP | SERVICE_PAUSE_CONTINUE) function to get handle to the service failed (0X424=1060)

Thursday, May 23, 2013

The best way to build InfoPath forms

For most of the InfoPath form system, the development of forms is always easy, even if there is some coding got involved.  The real problem is about form maintenance.

Let's imagine that you, as a SharePoint administrator or a InfoPath form developer, is in charge of 500 forms. Each form, on average, needs to be changed twice a year. So you need to modify 500 * 2 / 220 (work days) = 4.5 (forms per day).

What would happen if there are 5000 forms?

Based on my experience, most of the changes don't require to change the C# code. From technical point of view, they are just cosmetic changes. However, since C# code is part of the forms, developer have to do the changes! Or, do they?

Below is how I handle this situation. It minimizes the work of SharePoint administrator (or InfoPath developer).

1. Install InfoPath program on business users' computer.
.Net framework support is needed.

2. All forms and C# code are stored on SharePoint development server

3. Move form relevant C# code into a separate project.
Normally we need a dedicated project for each InfoPath system (a SharePoint site collection).
This project is a standard SharePoint feature (solution), which shared by all relevant forms of one project.

4. Share the form folder and C# assembly folder to relevant business users.
Business users can modify forms, but can only view C# assembly folder.




5. In form project, call the methods of that shared assembly to implement functionality.


6. Business users can modify the form whenever they want, and then deploy to another shared folder.
They can change all stuff except coding, which include rules, validation, data connection, text, views, etc.


7. Once they completed the changes, they can send an request to SharePoint administrator to deploy the changed forms to development environment or test environment.

8. SharePoint administrator deploy the new forms, then ask business users to test them.
Normally through PowerShell script.

9. Once the test is passed, these forms are ready to be deployed to Production.

What do you think of this procedure? Any comments are appreciated.


Monday, May 20, 2013

SharePoint 2010 "Out of the Box" Workflow intermittent error: "Failed to Start"

When copy data from MS Excel sheet to SharePoint list datasheet view, some items triggered workflow successfully, but some got "Failed to Start" error.  For the failed ones, if I delete them and try again, normally the errors disappeared.


There are one application server and two web front servers in the SharePoint farm. NLB (network load balancer) is created for the two web front end servers. The "Microsoft SharePoint Foundation Workflow Timer Service" service is running on the application server.




Let's keep this post short. I started the workflow timer service on all servers, then the problem is resolved.


I think there is a bug with SharePoint timer service (SharePoint 2010 + sp1 + CU201206), and it cannot handle NLB requests properly.

Wednesday, May 1, 2013

SharePoint 2013 Workflow trouble shooting


Error: "Something went wrong.  To try again, reload the page and then start the workflow again"

Environment: Windows Server 2012, SharePoint 2013 RTM + PU 201303, Workflow manager 1.0 + CU1

I configured workflow manager 1.0 for one SharePoint 2013 farm. It worked well.  However, when I tried to do similar configuration for another SP2013 farm (belongs to another domain), I got the error message above. Blow is the details in SharePoint log.

Exception returned from back end service. System.ServiceModel.Security.MessageSecurityException: The HTTP request was forbidden with client authentication scheme 'Anonymous'. ---> System.Net.WebException: The remote server returned an error: (403) Forbidden.    
 at System.Net.HttpWebRequest.GetResponse()    
 at System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)     -
 -- End of inner exception stack trace ---    Server stack trace:     
 at System.ServiceModel.Channels.HttpChannelUtilities.ValidateAuthentication(HttpWebRequest request, HttpWebResponse response, WebException responseException, HttpChannelFactory`1 factory)    
 at System.ServiceModel.Channels.HttpChannelUtilities.ValidateRequestReplyResponse(HttpWebRequest request, HttpWebResponse response, HttpChannelFactory`1 factory, WebException responseException, ChannelBinding channelBinding)    
 at System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)    
 at System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout)    
 at System.ServiceModel.Channels.SecurityChannelFactory`1.SecurityRequestChannel.Request(Message message, TimeSpan timeout)    
 at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)    
 at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)    
 at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)    Exception rethrown
 at [0]:     
 at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)    
 at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)    
 at Microsoft.SharePoint.Taxonomy.IMetadataWebServiceApplication.GetServiceSettings(Guid rawPartitionId)    
 at Microsoft.SharePoint.Taxonomy.MetadataWebServiceApplicationProxy.<>c__DisplayClass32.b__31(IMetadataWebServiceApplication serviceApplication)    
 at Microsoft.SharePoint.Taxonomy.MetadataWebServiceApplicationProxy.<>c__DisplayClass2f.b__2d()

Search engine told me that it might caused by incorrect web application authentication mode. The PowerShell command "convert-spwebapplication -identity http://mywebapp -To Claims -RetainPermission" doesn't work well, so I rebuilt the web application with "Claims" authentication.

Now, I can create SharePoint 2013 workflow in SharePoint Designer 2013. But, when trying to trigger that workflow, the workflow status was kept as "Started" for a few minutes, then been turned into "Suspended".

Below is the error message from SharePoint log file.

Original error: System.UnauthorizedAccessException: Attempted to perform an unauthorized operation.   
 at Microsoft.SharePoint.SPGlobal.HandleUnauthorizedAccessException(UnauthorizedAccessException ex)   
 at Microsoft.SharePoint.SPSecurableObject.CheckPermissions(SPBasePermissions permissionMask)   
 at Microsoft.SharePoint.Client.SPClientServiceHost.OnBeginRequest()   
 at Microsoft.SharePoint.Client.Rest.RestService.ProcessQuery(Stream inputStream, IList`1 pendingDisposableContainer)

SocialRESTExceptionProcessingHandler.DoServerExceptionProcessing - SharePoint Server Exception [System.UnauthorizedAccessException: Attempted to perform an unauthorized operation.   
 at Microsoft.SharePoint.SPGlobal.HandleUnauthorizedAccessException(UnauthorizedAccessException ex)   
 at Microsoft.SharePoint.SPSecurableObject.CheckPermissions(SPBasePermissions permissionMask)   
 at Microsoft.SharePoint.Client.SPClientServiceHost.OnBeginRequest()   
 at Microsoft.SharePoint.Client.Rest.RestService.ProcessQuery(Stream inputStream, IList`1 pendingDisposableContainer)]

Throw UnauthorizedAccessException instead of SPUtilityInternal.Send401 for client.svc request.

Application error when access /_vti_bin/client.svc, Error=Cannot redirect after HTTP headers have been sent. 
 at System.Web.HttpResponse.Redirect(String url, Boolean endResponse, Boolean permanent)   
 at System.Web.HttpApplication.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()   
 at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)


On workflow server, I got these error information from windows events log.

Faulting application name: Microsoft.Workflow.ServiceHost.exe, version: 1.0.20922.0, time stamp: 0x505e1b24
Faulting module name: KERNELBASE.dll, version: 6.1.7601.18015, time stamp: 0x50b8479b
Exception code: 0xe0434352
Fault offset: 0x0000000000009e5d
Faulting process id: 0x584
Faulting application start time: 0x01ce34b1db568cd3
Faulting application path: C:\Program Files\Workflow Manager\1.0\Workflow\Artifacts\Microsoft.Workflow.ServiceHost.exe
Faulting module path: C:\Windows\system32\KERNELBASE.dll
Report Id: 1c0e9293-a0a5-11e2-9b79-005056b4129c

Application: Microsoft.Workflow.ServiceHost.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: Microsoft.Workflow.Common.FatalException
Stack:
   at Microsoft.Workflow.Common.Fx+<>c__DisplayClass2.b__0()
   at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
   at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
   at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
   at System.Threading.ThreadHelper.ThreadStart()


Don't know what caused it. After quite a lot of struggling, I simply gave it up.

Last week, SharePoint 2013 CU 201304 was released. After installing it, BANG! The problem disappeared!