我正在使用 Microsoft 的 WF 4.5,并且在很大程度上取得了成功。我将它用于内部网站,因此在我们的域中使用 Windows 身份验证。但是,我偶然发现了一个错误,我无法解决。
每当我尝试在 web.config 中启用 sqlWorkflowInstanceStore 时,Workflow 在尝试将 System.ServiceModel.ServiceSecurityContext.Current.WindowsIdentity.Name 分配给变量时都会引发异常。
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)
下面是我的 web.config(密码被故意屏蔽了)
<?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>
如果我注释掉 sqlWorkflowInstanceStore,那么 WindowsIdentity.Name 就会恢复正常。
任何想法为什么?