I'm using Microsoft's WF 4.5 and have largely been quite successful with it. I'm using it for an internal website and therefore making use of Windows authentication within our domain. I have stumbled across an error, however, that i'm unable to resolve.
Whenever I try to enable the sqlWorkflowInstanceStore in web.config, the Workflow throws an exception when it attempt to assign System.ServiceModel.ServiceSecurityContext.Current.WindowsIdentity.Name to a variable.
Object reference not set to an instance of an object.
Server stack trace:
at System.ServiceModel.Channels.ServiceChannel.ThrowIfFaultUnderstood(Message reply, MessageFault fault, String action, MessageVersion version, FaultConverter faultConverter)
at System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc& rpc)
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 IService.SubmitWorkHours(Int32[]& p_workHours)
at ServiceClient.SubmitWorkHours(Int32[]& p_workHours)
Below is my web.config (password has purposely been masked)
<?xml version="1.0"?>
<configuration>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IService" sendTimeout="00:05:00">
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Windows"/>
</security>
</binding>
</basicHttpBinding>
</bindings>
<services>
<service name="Service1" behaviorConfiguration="WindowsAuthenticationBehavior">
<endpoint address="http://localhost/SimpleTimesheetService/TimesheetApproval.xamlx" binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_IService" contract="IService" name="BasicHttpBinding_IService"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="WindowsAuthenticationBehavior">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
<serviceCredentials>
<windowsAuthentication includeWindowsGroups="true" allowAnonymousLogons="false"/>
</serviceCredentials>
<serviceAuthorization principalPermissionMode="UseWindowsGroups" />
<sqlWorkflowInstanceStore instanceCompletionAction="DeleteAll" instanceEncodingOption="GZip" instanceLockedExceptionAction="NoRetry" connectionString="server=D801903;database=AppFabPersist;PWD=*******;UID=sa;" hostLockRenewalPeriod="00:00:30" runnableInstancesDetectionPeriod="00:00:05" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
<system.web>
<authentication mode="Windows" />
<compilation debug="true"/>
</system.web>
</configuration>
If I comment out the sqlWorkflowInstanceStore, then the WindowsIdentity.Name comes back fine.
Any ideas why?
In workflow 4.0 and probably 4.5 , the context does not expose the OperationContext and thus the ServiceSecurityContext.
If you have an alternative solution let me know