I have a web service running, and it uses Spring.NET for it's IoCness. One of the classes needs to do some stuff when it loads (I'm using AfterPropertiesSet
) and "some stuff" involves a call to ContextRegistry.GetContext()
. The problem is this code in the ContextRegistry
class:
if (rootContextCurrentlyInCreation)
{
throw new InvalidOperationException("root context is currently in creation. You must not call ContextRegistry.GetContext() from e.g. constructors of your singleton objects");
}
How can I have that object register itself to be notified once the context is fully created?
if possible, remove that call to
ContextRegistry.GetContext()
. That is a sign of bad design anyway because it couples your code very closely to the container - which I think we all agree shouldn't be the case.What exactly are you trying to do?
P.S: I'd also like to suggest you post Spring for .NET relevant questions to our community forums - it is more likely to get your questions answered there.