Cannot be used for communication because it is in the Faulted state

Okay, so: You finished installing MIM 2016, the world is looking good and you get some bad ass events in the eventlog when restarting the FIMService that looks like this:

Problem

Workflow host activation failed for workflow definition id : 303cac16-d927-41f6-abce-21ccbd883ea2, version key: 6. Exception: The communication object, Microsoft.ResourceManagement.Workflow.Hosting.ResourceManagementWorkflowServiceHost, cannot be used for communication because it is in the Faulted state. at System.ServiceModel.Channels.CommunicationObject.Close(TimeSpan timeout)
at Microsoft.ResourceManagement.Workflow.Hosting.HostActivator.CloseServiceHosts(IList`1 workflowServiceHosts)
at Microsoft.ResourceManagement.Workflow.Hosting.HostActivator.ActivateHost(ResourceManagementWorkflowDefinition workflowDefinition, Boolean suspendWorkflowStartupAndTimerOperations)
at Microsoft.ResourceManagement.Workflow.Hosting.HostActivator.RetrieveWorkflowDataForHostActivator()

Microsoft.ResourceManagement.Service: System.NullReferenceException: Object reference not set to an instance of an object.
at Microsoft.ResourceManagement.Workflow.Hosting.SqlWorkItemSchedulerService.OnStopped()
at System.EventHandler`1.Invoke(Object sender, TEventArgs e)
at System.Workflow.Runtime.WorkflowRuntime.StopRuntime()
at Microsoft.ResourceManagement.Workflow.Hosting.HostActivator.StopAndCloseWorkflowHost(Object serviceHostObj)</em>

mscorlib: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---&gt; System.ObjectDisposedException: Cannot access a disposed object.
Object name: 'WorkflowRuntime'.
at System.Workflow.Runtime.WorkflowRuntime.VerifyInternalState()
at System.Workflow.Runtime.WorkflowRuntime.GetLoadedWorkflows()
at Microsoft.ResourceManagement.Workflow.Hosting.HostActivator.StopAndCloseWorkflowHost(Object serviceHostObj)
--- End of inner exception stack trace ---
at System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct&amp; sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
at System.Delegate.DynamicInvokeImpl(Object[] args)
at Microsoft.ResourceManagement.Utilities.ThreadManager.ProcessCallBack(Object stateObj)

Workflow host activation failed for workflow definition id : f6d0bfce-df36-4756-98a2-cb8917428bae, version key: 1. Exception: The requested Performance Counter is not a custom counter, it has to be initialized as ReadOnly. at System.Diagnostics.PerformanceCounter.Initialize()
at System.Diagnostics.PerformanceCounter..ctor(String categoryName, String counterName, String instanceName, Boolean readOnly)
at System.Workflow.Runtime.PerformanceCounterManager.CreateCounters(String name)
at System.Workflow.Runtime.Hosting.DefaultWorkflowSchedulerService.OnStarted()
at System.EventHandler`1.Invoke(Object sender, TEventArgs e)
at System.Workflow.Runtime.WorkflowRuntime.StartRuntime()
at Microsoft.ResourceManagement.Workflow.Hosting.HostActivator.ActivateHost(ResourceManagementWorkflowDefinition workflowDefinition, Boolean suspendWorkflowStartupAndTimerOperations)
at Microsoft.ResourceManagement.Workflow.Hosting.HostActivator.RetrieveWorkflowDataForHostActivator()

A WorkflowServiceHost instance for WorkflowDefinitionVersionKey '6' has faulted.

Workflow host activation failed for workflow definition id : 303cac16-d927-41f6-abce-21ccbd883ea2, version key: 6. Exception: The communication object, Microsoft.ResourceManagement.Workflow.Hosting.ResourceManagementWorkflowServiceHost, cannot be used for communication because it is in the Faulted state. at System.ServiceModel.Channels.CommunicationObject.Close(TimeSpan timeout)
at Microsoft.ResourceManagement.Workflow.Hosting.HostActivator.CloseServiceHosts(IList`1 workflowServiceHosts)
at Microsoft.ResourceManagement.Workflow.Hosting.HostActivator.ActivateHost(ResourceManagementWorkflowDefinition workflowDefinition, Boolean suspendWorkflowStartupAndTimerOperations)
at Microsoft.ResourceManagement.Workflow.Hosting.HostActivator.RetrieveWorkflowDataForHostActivator()

If you take a look at the actual workflows
Note: The workflow with ID «303cac16-d927-41f6-abce-21ccbd883ea2” is “Owner Approval Workflow”

Also the following workflows is repeated with error:
• Password Reset Action Workflow
• Password Reset AuthN Workflow
• PAM: Request Authorization

Solution

For some reason I was missing a couple of registry entries in: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Windows Workflow Foundation 3.0.0.0\Performance, and this was causing the error. I took a screenshot of a healthy MIM server and manually created the missing entries, this is how it should look like:

snip_20160317090606

Make the registry look like the screenshot and do a restart of MIMService, all your troubles should be gone.

Other tips

I know, from troubleshooting this _a lot_ that some may experience a problem where the built-in WFs XOML is referencing the wrong .NET version. This blog is talking about this issue with a solution: http://blog.predica.pl/fim-2010-authorization-workflow-fails-with-eventid-3/

Also somebody has experienced this error when doing SSPR