0

IIS 7 で wcf サービスを構築しました。

共有データに問題があります。

他のサービスから静的データにアクセスしようとすると、実行時にエラーが発生します。

サービス 1

[ServiceContract(Name="ServiceChat", CallbackContract=typeof(IChatCallback))]
public ChatService { 
     static int counter;
     ...
}

サービス 2

[ServiceContract(Name="ServiceAvatar", CallbackContract=typeof(IAvatarCallback))]
public AvatarService {
     [OperationContract] 
     public int Test {
          return ChatService.counter; // Throw error
     }
     ...
}
4

1 に答える 1

0

As per my understanindg . You want to share a centralized static data among different resourses.

Why dont you decorate your WCF contract with [ServiceBehavior(InstanceContextMode=InstanceContextMode.Single)]

This will create only one session and all the clients are accessing your services through the same session.

So its like they all get the same source .

Hope this helps.

于 2011-12-14T02:33:18.287 に答える