Spring.Net IoC Application Context

I got the following "problem". I have created an application context file for spring.net. The configuration looks like this:

<spring>
    <context>
        <resource uri="config://spring/objects"/>
    </context>
    <objects configSource="SpringObjects.config" />
</spring>

      

I was told that if you change something in the context of the application, you do not need to recompile the application to see the changes.

Anyway if I changed something in the config file. No changes are visible. This is still the original data that is visible.

I am calling the application context like this:

IApplicationContext ctx = ContextRegistry.GetContext();
    ManagementConfigurator configurator = (ManagementConfigurator)ctx.GetObject("ManagementConfigurator");

      

Sometimes it takes some time to change the changes (even after the application is recompiled).

EDIT: I just found out that you need to restart the application pool. I am just rephrasing my question: "Can you reload the application context in your application?" No need to restart the application pool.

0


source to share


1 answer


The application pool does not need to be restarted, and the AppDomain associated with the executable code needs to be reworked. I don't know if this is an option for you, but if you put spring objects in the web.config file instead of a separate file and you change the web.config file (for example changing spring in it) the associated AppDomain will be reworked, which should also mean that your application will be reconfigured again. You can also just change your SpringObjects.config file and then click "web.config". (I'm not sure if the positive SpringObjects.config example in the bin directory is a good idea, but a change in the bin directory also rework the AppDomain)



You can use the ContextRegistry (Clear and then RegisterContext) methods programmatically to reload the ApplicationContext, although I wouldn't recommend it.

+2


source







All Articles