diff --git a/src/Tools/Orchard/Host/CommandHost.cs b/src/Tools/Orchard/Host/CommandHost.cs
index 7f6d58c9a..a2585b164 100644
--- a/src/Tools/Orchard/Host/CommandHost.cs
+++ b/src/Tools/Orchard/Host/CommandHost.cs
@@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
+using System.Security;
using System.Web.Hosting;
using Orchard.Parameters;
using Orchard.ResponseFiles;
@@ -19,11 +20,13 @@ namespace Orchard.Host {
HostingEnvironment.RegisterObject(this);
}
+ [SecurityCritical]
public override object InitializeLifetimeService() {
// never expire the license
return null;
}
+ [SecuritySafeCritical]
void IRegisteredObject.Stop(bool immediate) {
HostingEnvironment.UnregisterObject(this);
}
diff --git a/src/Tools/Orchard/HostContext/CommandHostContext.cs b/src/Tools/Orchard/HostContext/CommandHostContext.cs
index d2b139360..5d6f15956 100644
--- a/src/Tools/Orchard/HostContext/CommandHostContext.cs
+++ b/src/Tools/Orchard/HostContext/CommandHostContext.cs
@@ -9,8 +9,6 @@ namespace Orchard.HostContext {
public DirectoryInfo OrchardDirectory { get; set; }
public int StartSessionResult { get; set; }
public bool DisplayUsageHelp { get; set; }
- public ApplicationManager AppManager { get; set; }
- public ApplicationObject AppObject { get; set; }
public CommandHost CommandHost { get; set; }
public Logger Logger { get; set; }
}
diff --git a/src/Tools/Orchard/HostContext/CommandHostContextProvider.cs b/src/Tools/Orchard/HostContext/CommandHostContextProvider.cs
index 1c612ed30..da1ed52dd 100644
--- a/src/Tools/Orchard/HostContext/CommandHostContextProvider.cs
+++ b/src/Tools/Orchard/HostContext/CommandHostContextProvider.cs
@@ -3,7 +3,9 @@ using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
+using System.Security;
using System.Web;
+using System.Web.Compilation;
using System.Web.Hosting;
using Orchard.Host;
using Orchard.Parameters;
@@ -20,6 +22,7 @@ namespace Orchard.HostContext {
_args = args;
}
+ [SecurityCritical]
public CommandHostContext CreateContext() {
var context = new CommandHostContext();
context.RetryResult = 240;/*special return code for "Retry"*/
@@ -27,6 +30,7 @@ namespace Orchard.HostContext {
return context;
}
+ [SecurityCritical]
public void Shutdown(CommandHostContext context) {
try {
if (context.CommandHost != null) {
@@ -38,9 +42,9 @@ namespace Orchard.HostContext {
LogInfo(context, " (AppDomain already unloaded)");
}
- if (context.AppObject != null) {
+ if (context.CommandHost != null) {
LogInfo(context, "Shutting down ASP.NET AppDomain...");
- context.AppManager.ShutdownApplication(context.AppObject.ApplicationId);
+ ApplicationManager.GetApplicationManager().ShutdownAll();
}
}
@@ -72,9 +76,7 @@ namespace Orchard.HostContext {
LogInfo(context, "Orchard root directory: \"{0}\"", context.OrchardDirectory.FullName);
LogInfo(context, "Creating ASP.NET AppDomain for command agent...");
- context.AppManager = ApplicationManager.GetApplicationManager();
- context.AppObject = CreateWorkerAppDomainWithHost(context.AppManager, context.Arguments.VirtualPath, context.OrchardDirectory.FullName, typeof(CommandHost));
- context.CommandHost = (CommandHost)context.AppObject.ObjectInstance;
+ context.CommandHost = CreateWorkerAppDomainWithHost(context.Arguments.VirtualPath, context.OrchardDirectory.FullName, typeof(CommandHost));
LogInfo(context, "Starting Orchard session");
context.StartSessionResult = context.CommandHost.StartSession(_input, _output);
@@ -113,29 +115,9 @@ namespace Orchard.HostContext {
string.Format("Directory \"{0}\" doesn't seem to contain an Orchard installation", new DirectoryInfo(directory).FullName));
}
- private static ApplicationObject CreateWorkerAppDomainWithHost(ApplicationManager appManager, string virtualPath, string physicalPath, Type hostType) {
- // this creates worker app domain in a way that host doesn't need to be in GAC or bin
- // using BuildManagerHost via private reflection
- string uniqueAppString = string.Concat(virtualPath, physicalPath).ToLowerInvariant();
- string appId = (uniqueAppString.GetHashCode()).ToString("x", CultureInfo.InvariantCulture);
-
- // create BuildManagerHost in the worker app domain
- var buildManagerHostType = typeof(HttpRuntime).Assembly.GetType("System.Web.Compilation.BuildManagerHost");
- var buildManagerHost = appManager.CreateObject(appId, buildManagerHostType, virtualPath, physicalPath, false);
-
- // call BuildManagerHost.RegisterAssembly to make Host type loadable in the worker app domain
- buildManagerHostType.InvokeMember(
- "RegisterAssembly",
- BindingFlags.Instance | BindingFlags.InvokeMethod | BindingFlags.NonPublic,
- null,
- buildManagerHost,
- new object[] { hostType.Assembly.FullName, hostType.Assembly.Location });
-
- // create Host in the worker app domain
- return new ApplicationObject {
- ApplicationId = appId,
- ObjectInstance = appManager.CreateObject(appId, hostType, virtualPath, physicalPath, false)
- };
+ private static CommandHost CreateWorkerAppDomainWithHost(string virtualPath, string physicalPath, Type hostType) {
+ ClientBuildManager clientBuildManager = new ClientBuildManager(virtualPath, physicalPath);
+ return (CommandHost)clientBuildManager.CreateObject(hostType, false);
}
}
}
diff --git a/src/Tools/Orchard/Orchard.csproj b/src/Tools/Orchard/Orchard.csproj
index 2ab5f66e3..76d2a8520 100644
--- a/src/Tools/Orchard/Orchard.csproj
+++ b/src/Tools/Orchard/Orchard.csproj
@@ -71,7 +71,6 @@
-
diff --git a/src/Tools/Orchard/OrchardParametersParser.cs b/src/Tools/Orchard/OrchardParametersParser.cs
index 1dca13a99..318939b28 100644
--- a/src/Tools/Orchard/OrchardParametersParser.cs
+++ b/src/Tools/Orchard/OrchardParametersParser.cs
@@ -1,10 +1,11 @@
using System;
using System.Collections.Generic;
+using System.Security;
using Orchard.Parameters;
namespace Orchard {
public class OrchardParametersParser : IOrchardParametersParser {
-
+ [SecurityCritical]
public OrchardParameters Parse(CommandParameters parameters) {
var result = new OrchardParameters {
diff --git a/src/Tools/Orchard/Parameters/CommandLineParser.cs b/src/Tools/Orchard/Parameters/CommandLineParser.cs
index 35eed1861..e334d62f5 100644
--- a/src/Tools/Orchard/Parameters/CommandLineParser.cs
+++ b/src/Tools/Orchard/Parameters/CommandLineParser.cs
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
+using System.Security;
using System.Text;
namespace Orchard.Parameters {
@@ -8,6 +9,7 @@ namespace Orchard.Parameters {
}
public class CommandLineParser : ICommandLineParser {
+ [SecurityCritical]
public IEnumerable Parse(string commandLine) {
return SplitArgs(commandLine);
}
diff --git a/src/Tools/Orchard/Parameters/CommandParametersParser.cs b/src/Tools/Orchard/Parameters/CommandParametersParser.cs
index 8783bb603..b4227c8cf 100644
--- a/src/Tools/Orchard/Parameters/CommandParametersParser.cs
+++ b/src/Tools/Orchard/Parameters/CommandParametersParser.cs
@@ -1,8 +1,10 @@
using System;
using System.Collections.Generic;
+using System.Security;
namespace Orchard.Parameters {
public class CommandParametersParser : ICommandParametersParser {
+ [SecurityCritical]
public CommandParameters Parse(IEnumerable args) {
var result = new CommandParameters {
Arguments = new List(),
diff --git a/src/Tools/Orchard/Properties/AssemblyInfo.cs b/src/Tools/Orchard/Properties/AssemblyInfo.cs
index cce9bf430..287e20a7b 100644
--- a/src/Tools/Orchard/Properties/AssemblyInfo.cs
+++ b/src/Tools/Orchard/Properties/AssemblyInfo.cs
@@ -1,6 +1,7 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
+using System.Security;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
@@ -34,3 +35,4 @@ using System.Runtime.InteropServices;
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.8.0")]
[assembly: AssemblyFileVersion("0.8.0")]
+[assembly: SecurityCritical]
\ No newline at end of file