tag:blogger.com,1999:blog-3173083849654637033.post5993376779458795176..comments2019-07-03T04:43:54.220-04:00Comments on Drew.NET: Unity lifetime managers and WCF IntegrationDrewhttp://www.blogger.com/profile/08026650581140911372noreply@blogger.comBlogger10125tag:blogger.com,1999:blog-3173083849654637033.post-74975814797150643812010-05-14T19:20:59.448-04:002010-05-14T19:20:59.448-04:00@Jon - The IInstanceProvider.ReleaseInstance() isn...@Jon - The IInstanceProvider.ReleaseInstance() isn't being called? What binding are you using for your service? As far as I know, this should work.Drewhttps://www.blogger.com/profile/08026650581140911372noreply@blogger.comtag:blogger.com,1999:blog-3173083849654637033.post-87075444092821502332010-05-14T19:17:43.388-04:002010-05-14T19:17:43.388-04:00Sorry all for the lack of responses to the comment...Sorry all for the lack of responses to the comments. Work has been insane. I will try to answer the questions in order.<br /><br />@Anonymous - Good catch. Your solution should work fine. However, I believe the "correct" approach, judging by the documentation, is to detach the extension in the IInstanceProvider.ReleaseInstance() method. You should be able to find the IExtension<> and call detach. I will try to make this change and update soon.<br /><br />@Roberto - The self-hosted service was simply for a simple, sample application. We are using the exact same code in an IIS hosted service today. It works exactly the same.Drewhttps://www.blogger.com/profile/08026650581140911372noreply@blogger.comtag:blogger.com,1999:blog-3173083849654637033.post-73513597711941326972010-03-11T16:01:29.953-05:002010-03-11T16:01:29.953-05:00Hi, I'm implementing my own IINstanceProvider ...Hi, I'm implementing my own IINstanceProvider class but the Release() method never gets called? It's implemented using an IServiceBehavior and attached to the exposed endpoints. No matter how hard we hammer the service the Relaease() method nevers gets called. We can the service running a per call instanceContext mode with 50 instance max. The deconstruct of the instances gets called but this looks like the gargageCollection rather than wcf realeasing and disposing. An ideas?Unknownhttps://www.blogger.com/profile/03493052414109999771noreply@blogger.comtag:blogger.com,1999:blog-3173083849654637033.post-52391987578888795892010-03-09T07:54:58.332-05:002010-03-09T07:54:58.332-05:00You made my day. Awesome code.
I just had to chang...You made my day. Awesome code.<br />I just had to change some details within UnityInstanceProvider and now everything works perfectly in my environment.<br /><br />You should definitly publish this on CodePlex.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-3173083849654637033.post-16758979005322848212009-12-07T10:00:44.564-05:002009-12-07T10:00:44.564-05:00This is just perfect.
I have had a similar proble...This is just perfect.<br /><br />I have had a similar problem using Telerik OpenAccess, but in essense the problem is the exact same. I was using ObjectBuilder and a specific strategy to handle this, because no Unity existed at that moment in time... but this.. It's brilliant as Marcelo already said.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-3173083849654637033.post-41157515874249267202009-12-02T21:23:27.912-05:002009-12-02T21:23:27.912-05:00This makes sense when you host the services yourse...This makes sense when you host the services yourself, but, how would you transform this sample to use it when the services are hosted in IIS?Robertonoreply@blogger.comtag:blogger.com,1999:blog-3173083849654637033.post-82615108999840076702009-10-13T23:11:35.577-04:002009-10-13T23:11:35.577-04:00Great example. I tried using the UnityInstanceCon...Great example. I tried using the UnityInstanceContextLifetimeManager and found that dispose wasn't being called on the objects registered. The fix was to subscribe to the Closing event on the InstanceContext in the UnityInstanceContextExtension and call Detach on the current UnityInstanceContextExtension instance.<br /><br />Is there a better way?Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-3173083849654637033.post-80089995904931708762009-08-21T15:53:24.471-04:002009-08-21T15:53:24.471-04:00I second the request to upload this to CodePlex. A...I second the request to upload this to CodePlex. Along with my kudos on this...and the only word that seems fitting......Brilliant !Marcelo Lhttp://del.icio.usnoreply@blogger.comtag:blogger.com,1999:blog-3173083849654637033.post-5411372936775526172009-07-31T11:38:13.313-04:002009-07-31T11:38:13.313-04:00Sorry. I sent that last post before I took a good ...Sorry. I sent that last post before I took a good look at the download. It does a heap more than our simple solution and it's actually pretty awesome. Please upload this to CodePlex.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-3173083849654637033.post-1563805942580932212009-07-31T11:15:22.963-04:002009-07-31T11:15:22.963-04:00We're doing something similar on my current pr...We're doing something similar on my current project with Unity and Linq to SQL. <br /><br />The approach we took was to make an implementation of IInstanceProvider. The IInstanceProvider holds a static Unity container which includes all the type dependencies. When GetInstance is called it creates a child container and registers instance dependencies with it. The service instance is pulled from this container and then the container is stashed on the instance context. When ReleaseInstance is called we do some cleanup and dispose the child container. The IInstanceProvider gets hooked up by a IContractBehaviorAttribute.<br /><br />IMO, this is a much simpler approach. It's certainly less code.Anonymousnoreply@blogger.com