Results 1 to 2 of 2

Thread: DI and InstanceContextMode.Single

  1. #1
    Join Date
    Aug 2008
    Posts
    4

    Default DI and InstanceContextMode.Single

    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

  2. #2
    Join Date
    Oct 2005
    Location
    Toulouse, France
    Posts
    1,407

    Default

    Hi,

    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.


    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 :
    Code:
    // Programmatically (You need to comment 'ServiceExporter' object definition in App.config)
    using (ServiceHost serviceHost = new ServiceHost("calculator"))
    {
        serviceHost.Open();
    
        Console.Out.WriteLine("Server listening...");
        Console.Out.WriteLine("--- Press <return> to quit ---");
        Console.ReadLine();
    }
    The problem is that ServiceExporter also start a ServiceHost, and it should not.


    - Bruno
    Last edited by Bruno Baia; 08-04-2008 at 10:29 AM.
    My english is as poor as my taylor is rich

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •