Display an error message in command line on app domain restart

With dynamic compilation, it is sometimes necessary to restart the AppDomain.
In the command line scenario, instead of restarting the appdomain, we throw
an exception with an descriptive error message.

--HG--
branch : dev
This commit is contained in:
Renaud Paquay 2010-07-07 17:45:59 -07:00
parent 293cfa91ce
commit 320019b8c6
2 changed files with 10 additions and 2 deletions

View File

@ -2,9 +2,16 @@ using System;
using System.Linq;
using System.Web.Hosting;
using Orchard.Environment;
using Orchard.Localization;
namespace Orchard.Commands {
public class CommandHostEnvironment : IHostEnvironment {
public CommandHostEnvironment() {
T = NullLocalizer.Instance;
}
public Localizer T { get; set; }
public bool IsFullTrust {
get { return AppDomain.CurrentDomain.IsFullyTrusted; }
}
@ -18,11 +25,11 @@ namespace Orchard.Commands {
}
public void RestartAppDomain() {
//Don't restart AppDomain in command line environment
ResetSiteCompilation();
}
public void ResetSiteCompilation() {
//Don't restart AppDomain in command line environment
throw new OrchardCoreException(T("A change of configuration requires the application to be restarted. Running the command again usually solves this problem."));
}
}
}

View File

@ -45,6 +45,7 @@ namespace Orchard.Environment.Extensions.Loaders {
Logger.Information("ExtensionRemoved: Deleting assembly \"{0}\" from bin directory (AppDomain will restart)", moduleName);
File.Delete(_virtualPathProvider.MapPath(assemblyPath));
});
ctx.RestartAppDomain = true;
}
}