0

我正在使用 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 就会恢复正常。

任何想法为什么?

4

1 回答 1

0

在工作流 4.0 和可能的 4.5 中,上下文不公开 OperationContext,因此也不公开 ServiceSecurityContext。

如果您有替代解决方案,请告诉我

于 2014-01-09T16:18:08.463 回答