1

This school semester I am building an MVC framework site that will be used for the automation of my janitor's house. Funny story actually. The Git page: https://github.com/LarsGardien/EniacHome/tree/master/MVC_default

I decided to use a pluggable architecture so some second years students could create their own widgets for this project and tune them for their hardware(Temp sensors and cameras). The Plugin logic: http://www.codeproject.com/Articles/614767/NET-ASP-NET-MVC-plug-in-architecture-with-embedded

The problem is that i can't add or delete plugin assemblies at runtime(/Admin/Plugin/(Add/Delete)), since they need to be added as a reference to the project like so:

BuildManager.AddReferencedAssembly(asmbly) //see PluginManager.PluginInitiator

Because this is a PreApplicationStartMethod, the application needs to be re-started. I thought of an AppPool Recycle:

ServerManager serverManager = ServerManager.OpenRemote(Environment.MachineName);
        ApplicationPool appPool = serverManager.ApplicationPools["EniacHome"];
        if (appPool != null)
        {
            if (appPool.State == ObjectState.Stopped)
            {
                appPool.Start();
            }
            else
            {
                appPool.Recycle();
            }
        }

So this is the deal: When using Plugin/Delete the App gets restarted after the recycle(verified with logging each assembly that gets added) but the plugin isn't removed(not from temp folder, gets rereferenced). When the delete action is called again, still nothing. But when an AppPool Recycle is called from the IIS Manager, it works: the plugin gets removed, the app starts and the url isn't accessible anymore.

When using Plugin/Add the new plugin gets referenced after the recycle(again verified with logging), but it's routes don't get registered. But again after an IIS Manager recycle everything seems to work properly.

So although the app gets restarted when calling a recycle programmatically, it doesn't include the right references.

Mlezi
  • 105
  • 1
  • 13
  • Possible duplicate of [Restarting (Recycling) an Application Pool](http://stackoverflow.com/questions/249927/restarting-recycling-an-application-pool) – Dhaval Patel Jan 06 '16 at 08:50

1 Answers1

0

Try adding a batch job to automate/schedule the delete of temporary files on the server. Then test the recycle of application pool.

Nate
  • 76
  • 3
  • Thanks for the tip, the appPool Recycle works after the temp files deletion. Though this is a weighty solution. In my case this is fine, but a somewhat more speedy solution would be welcome. Anyways, thanks for the help! – Mlezi Jan 06 '16 at 16:40