Adrian
Adrian

Reputation: 23

Two questions about WCF

Why, when defining classes that inherit from ClientBase<TChannel>, the service interface is "embedded" twice, one via composition (the generics in <TChannel>) and another via inheritance and not just one (like the composite one)?

On another thing, we make a successful call to a custom client proxy method which in place calls a method of the base.channel interface pointer, and we're having an issue where, upon next calling another client proxy function (which also redirects to another base.channel one), the base.channel property became null (so by the time the function is called), raising eventually a NullReferenceException. Why can this happen? (We create our ClientBase proxy with the default constructor, not providing any binding info). EDIT: The problem wasn't that the base.channel pointer is set to null after the first function call, it's that a new instance of the custom service gets created on each call. How to ensure same object is used through?

Upvotes: 1

Views: 60

Answers (1)

Adrian
Adrian

Reputation: 23

I found the answer to my second question. The solution (at least in our case) was to establish the following property: [ServiceBehavior(InstanceContextMode=InstanceContextMode.PerSession)], see here.

Nonetheless anyone is free to answer my first semantical question and I'll reward accordingly.

Upvotes: 1

Related Questions