Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Release policy for WcfService proxy dependency in object having PerWebRequest lifestyle

If I have a PerWebRequest object that has a wcf proxy dependency with a PerThread lifestyle, will the container

  • a) use the same proxy instance after the container auto-releases the parent object?
  • b) will the releasing of the PerWebRequest object cause the proxy to be released every time?

If a), then should I release the service explicitly to avoid leakage, or if b), is there any real benefit to using PerThread for the proxy if this is the only place it's being injected?

like image 218
kappasims Avatar asked Jun 11 '12 17:06

kappasims


1 Answers

Why would you make it per-thread? Per thread is a very specialised lifestyle and unless you really need it, I would suggest you avoid it.

Make the wcf proxy transient.

You don't have to release it. Here's how it works.

like image 60
Krzysztof Kozmic Avatar answered Oct 03 '22 15:10

Krzysztof Kozmic