View Full Version : DI and InstanceContextMode.Single
08-04-2008, 09:54 AM
Using the WcftQuickStart example, i get the following error when i change the instanceContextMode to Single(ton). Is there another way of starting up the DI container?
Error creating context 'spring.root': root context is currently in creation. You must not call ContextRegistry.GetContext() from e.g. constructors of your singleton objects
08-04-2008, 10:24 AM
thanks for reporting this.
We are investigating, and try to fix it for the WCF release.
Looks like there is the same pb with Oran Dennison approach (http://orand.blogspot.com/2006/10/wcf-service-dependency-injection.html).
A solution is to comment the ServiceExporter definition in the configuration file and use the programmatic way :
See Program.cs file in the Spring.WcfQuickStart.ServerApp console project :
// Programmatically (You need to comment 'ServiceExporter' object definition in App.config)
using (ServiceHost serviceHost = new ServiceHost("calculator"))
Console.Out.WriteLine("--- Press <return> to quit ---");
The problem is that ServiceExporter also start a ServiceHost, and it should not.
Powered by vBulletin® Version 4.2.0 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.