I am trying to use a DI Framework (namely MEF) with WCF, and was able to get everything working using the service factory, service host, instance provider approach as mentioned in various posts.
Everything works well till i introduce the singleton behavior on the serviceType.
Is there any way to participate in instance creation for a singleton service ?
Well, you learn something new every day. Singleton services don't use the IInstanceProvider, according to Carlos Figueira's blog . Why not seems to be a mystery, though. Can't find any info there.
If you want to use IoC with a Singleton service, you'll have to create the instance yourself and pass it into the ServiceHost's constructor.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.