아래 코드에서 언급 한 것처럼 wshttpbinding에서 InstanceContextMode.PerSession을 사용하고 있지만 카운트가 증가하지 않아 작동하지 않는 것 같습니다.InstanceContextMode.PerSession이 작동하지 않습니다.
상담하십시오. 클라이언트 전화
[ServiceContract(SessionMode = SessionMode.Required)]
public interface ITransService
{
[OperationContract(IsInitiating=true)]
int Insert(int userId);
[TransactionFlow(TransactionFlowOption.Allowed)]
[OperationContract]
int Update();
// TODO: Add your service operations here
}
[ServiceBehavior(InstanceContextMode = InstanceContextMode.PerSession)]
public class TransService : ITransService
{
public int count = 0;
[OperationBehavior(TransactionScopeRequired = true)]
public int Insert(int userId)
{
count = count+1;
return count;
}
[OperationBehavior(TransactionScopeRequired = true)]
public int Update()
{
count = count++;
return count;
}
}
---
using (TransactionScope tranScope = new TransactionScope())
{
TransServiceClient obj = new TransServiceClient();
var a= obj.Insert(123);
var b = obj.Insert(123);
var c = obj.Update();
tranScope.Complete();
}
I 라인 아래에 추가 및 내 서비스 참조를 업데이트하지만 행운은 [OperationContract를 (IsInitiating = TRUE)]을 – Dev
IsInitiating은에 간다 인터페이스 - 초기 게시물에 실수를 했습니까? 'SessionMode = SessionMode.Allowed'를'SessionMode.Required'로 변경하여 강제로 시도해 볼 수도 있습니다. – StuartLC
내 코드에서 동일한 내용을 업데이트하고 클라이언트 서비스 참조를 업데이트했지만 여전히 동일한 문제가 있습니다 .i하지 않습니다. 이 코드에서 내가 뭘하고 있는지 알 수 있습니다. – Dev