Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I find out when the Spring.NET root context has loaded?

Tags:

spring.net

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?

like image 939
Chris Marasti-Georg Avatar asked Dec 04 '25 20:12

Chris Marasti-Georg


1 Answers

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.

like image 162
Erich Eichinger Avatar answered Dec 08 '25 05:12

Erich Eichinger



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!