Added App_Code assembly loading to new type finder, had to recompile log4net to support medium trust.
Updated TypeFinder and assembly info to support medium trust.
This commit is contained in:
36
src/Umbraco.Core/AssemblyExtensions.cs
Normal file
36
src/Umbraco.Core/AssemblyExtensions.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
|
||||
namespace Umbraco.Core
|
||||
{
|
||||
internal static class AssemblyExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns the file used to load the assembly
|
||||
/// </summary>
|
||||
/// <param name="assembly"></param>
|
||||
/// <returns></returns>
|
||||
public static FileInfo GetAssemblyFile(this Assembly assembly)
|
||||
{
|
||||
var codeBase = assembly.CodeBase;
|
||||
var uri = new Uri(codeBase);
|
||||
var path = uri.LocalPath;
|
||||
return new FileInfo(path);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the file used to load the assembly
|
||||
/// </summary>
|
||||
/// <param name="assemblyName"></param>
|
||||
/// <returns></returns>
|
||||
public static FileInfo GetAssemblyFile(this AssemblyName assemblyName)
|
||||
{
|
||||
var codeBase = assemblyName.CodeBase;
|
||||
var uri = new Uri(codeBase);
|
||||
var path = uri.LocalPath;
|
||||
return new FileInfo(path);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1017,6 +1017,7 @@ namespace Umbraco.Core.Configuration
|
||||
}
|
||||
}
|
||||
|
||||
[Obsolete("This setting is not used anymore, the only file extensions that are supported are .cs and .vb files")]
|
||||
public static IEnumerable<string> AppCodeFileExtensionsList
|
||||
{
|
||||
get
|
||||
@@ -1027,7 +1028,7 @@ namespace Umbraco.Core.Configuration
|
||||
}
|
||||
}
|
||||
|
||||
[Obsolete("Use AppCodeFileExtensionsList instead")]
|
||||
[Obsolete("This setting is not used anymore, the only file extensions that are supported are .cs and .vb files")]
|
||||
public static XmlNode AppCodeFileExtensions
|
||||
{
|
||||
get
|
||||
|
||||
@@ -18,6 +18,8 @@ using System.Runtime.InteropServices;
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("130a6b5c-50e7-4df3-a0dd-e9e7eb0b7c5c")]
|
||||
|
||||
//[assembly: System.Security.SecurityRules(System.Security.SecurityRuleSet.Level1)]
|
||||
|
||||
[assembly: InternalsVisibleTo("umbraco")]
|
||||
[assembly: InternalsVisibleTo("Umbraco.Tests")]
|
||||
[assembly: InternalsVisibleTo("businesslogic")]
|
||||
|
||||
@@ -13,6 +13,8 @@ using System.Threading;
|
||||
using System.Web;
|
||||
using System.Web.Compilation;
|
||||
using System.Web.Hosting;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core.IO;
|
||||
|
||||
namespace Umbraco.Core
|
||||
{
|
||||
@@ -50,7 +52,7 @@ namespace Umbraco.Core
|
||||
{
|
||||
using (new WriteLock(Locker))
|
||||
{
|
||||
|
||||
List<Assembly> assemblies = null;
|
||||
try
|
||||
{
|
||||
var isHosted = HttpContext.Current != null;
|
||||
@@ -59,7 +61,8 @@ namespace Umbraco.Core
|
||||
{
|
||||
if (isHosted)
|
||||
{
|
||||
_allAssemblies = new ReadOnlyCollection<Assembly>(BuildManager.GetReferencedAssemblies().Cast<Assembly>().ToList());
|
||||
assemblies = new List<Assembly>(BuildManager.GetReferencedAssemblies().Cast<Assembly>());
|
||||
//_allAssemblies = new ReadOnlyCollection<Assembly>(BuildManager.GetReferencedAssemblies().Cast<Assembly>().ToList());
|
||||
}
|
||||
}
|
||||
catch (InvalidOperationException e)
|
||||
@@ -68,27 +71,21 @@ namespace Umbraco.Core
|
||||
throw;
|
||||
}
|
||||
|
||||
_allAssemblies = _allAssemblies ?? new ReadOnlyCollection<Assembly>(AppDomain.CurrentDomain.GetAssemblies().ToList());
|
||||
assemblies = assemblies ?? new List<Assembly>(AppDomain.CurrentDomain.GetAssemblies().ToList());
|
||||
//_allAssemblies = _allAssemblies ?? new ReadOnlyCollection<Assembly>(AppDomain.CurrentDomain.GetAssemblies().ToList());
|
||||
|
||||
//here we are getting just the /bin folder assemblies, we may need to use these if we implement the App_Plugins
|
||||
//stuff from v5.
|
||||
//here we are trying to get the App_Code assembly
|
||||
var fileExtensions = new[] {".cs", ".vb"}; //only vb and cs files are supported
|
||||
var appCodeFolder = new DirectoryInfo(IOHelper.MapPath(IOHelper.ResolveUrl("~/App_code")));
|
||||
//check if the folder exists and if there are any files in it with the supported file extensions
|
||||
if (appCodeFolder.Exists && (fileExtensions.Any(x => appCodeFolder.GetFiles("*" + x).Any())))
|
||||
{
|
||||
var appCodeAssembly = Assembly.Load("App_Code");
|
||||
assemblies.Add(appCodeAssembly);
|
||||
}
|
||||
|
||||
var codeBase = Assembly.GetExecutingAssembly().CodeBase;
|
||||
var uri = new Uri(codeBase);
|
||||
var path = uri.LocalPath;
|
||||
var binFolder = new DirectoryInfo(Path.GetDirectoryName(path));
|
||||
|
||||
var dllFiles = Directory.GetFiles(binFolder.FullName, "*.dll",
|
||||
SearchOption.TopDirectoryOnly).ToList();
|
||||
|
||||
var binFolderAssemblies = dllFiles.Select(AssemblyName.GetAssemblyName)
|
||||
.Select(assemblyName =>
|
||||
_allAssemblies.FirstOrDefault(a =>
|
||||
AssemblyName.ReferenceMatchesDefinition(a.GetName(), assemblyName)))
|
||||
.Where(locatedAssembly => locatedAssembly != null)
|
||||
.ToList();
|
||||
|
||||
_binFolderAssemblies = new ReadOnlyCollection<Assembly>(binFolderAssemblies);
|
||||
//now set the _allAssemblies
|
||||
_allAssemblies = new ReadOnlyCollection<Assembly>(assemblies);
|
||||
|
||||
}
|
||||
catch (InvalidOperationException e)
|
||||
@@ -104,6 +101,68 @@ namespace Umbraco.Core
|
||||
return _allAssemblies;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns only assemblies found in the bin folder that have been loaded into the app domain.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <remarks>
|
||||
/// This will be used if we implement App_Plugins from Umbraco v5 but currently it is not used.
|
||||
/// </remarks>
|
||||
internal static IEnumerable<Assembly> GetBinAssemblies()
|
||||
{
|
||||
|
||||
if (_binFolderAssemblies == null)
|
||||
{
|
||||
using (new WriteLock(Locker))
|
||||
{
|
||||
var assemblies = GetAssembliesWithKnownExclusions().ToArray();
|
||||
var binFolder = Assembly.GetExecutingAssembly().GetAssemblyFile().Directory;
|
||||
var binAssemblyFiles = Directory.GetFiles(binFolder.FullName, "*.dll", SearchOption.TopDirectoryOnly).ToList();
|
||||
var domainAssemblyNames = binAssemblyFiles.Select(AssemblyName.GetAssemblyName);
|
||||
var safeDomainAssemblies = new List<Assembly>();
|
||||
var binFolderAssemblies = new List<Assembly>();
|
||||
|
||||
foreach (var a in assemblies)
|
||||
{
|
||||
try
|
||||
{
|
||||
//do a test to see if its queryable in med trust
|
||||
var assemblyFile = a.GetAssemblyFile();
|
||||
safeDomainAssemblies.Add(a);
|
||||
}
|
||||
catch (SecurityException)
|
||||
{
|
||||
//we will just ignore this because this will fail
|
||||
//in medium trust for system assemblies, we get an exception but we just want to continue until we get to
|
||||
//an assembly that is ok.
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var assemblyName in domainAssemblyNames)
|
||||
{
|
||||
try
|
||||
{
|
||||
var foundAssembly = safeDomainAssemblies.FirstOrDefault(a => a.GetAssemblyFile() == assemblyName.GetAssemblyFile());
|
||||
if (foundAssembly != null)
|
||||
{
|
||||
binFolderAssemblies.Add(foundAssembly);
|
||||
}
|
||||
}
|
||||
catch (SecurityException)
|
||||
{
|
||||
//we will just ignore this because if we are trying to do a call to:
|
||||
// AssemblyName.ReferenceMatchesDefinition(a.GetName(), assemblyName)))
|
||||
//in medium trust for system assemblies, we get an exception but we just want to continue until we get to
|
||||
//an assembly that is ok.
|
||||
}
|
||||
}
|
||||
|
||||
_binFolderAssemblies = new ReadOnlyCollection<Assembly>(binFolderAssemblies);
|
||||
}
|
||||
}
|
||||
return _binFolderAssemblies;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return a list of found local Assemblies excluding the known assemblies we don't want to scan
|
||||
/// and exluding the ones passed in and excluding the exclusion list filter, the results of this are
|
||||
@@ -184,7 +243,6 @@ namespace Umbraco.Core
|
||||
"Examine."
|
||||
};
|
||||
|
||||
|
||||
public static IEnumerable<Type> FindClassesOfTypeWithAttribute<T, TAttribute>()
|
||||
where TAttribute : Attribute
|
||||
{
|
||||
|
||||
@@ -49,6 +49,7 @@
|
||||
<Link>Properties\SolutionInfo.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="ApplicationContext.cs" />
|
||||
<Compile Include="AssemblyExtensions.cs" />
|
||||
<Compile Include="Attempt.cs" />
|
||||
<Compile Include="CoreBootManager.cs" />
|
||||
<Compile Include="Resolving\ActionsResolver.cs" />
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="log4net, Version=1.2.11.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
|
||||
<Reference Include="log4net, Version=1.2.11.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\log4net.2.0.0\lib\net40-full\log4net.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="nunit.framework">
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
//
|
||||
// General Information about an assembly is controlled through the following
|
||||
@@ -11,8 +12,14 @@ using System.Runtime.CompilerServices;
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyProduct("Umbraco.Web.UI")]
|
||||
|
||||
//tg forcing .NET 2.0 security rules, since otherwise it wasn't possible to run in medium trust
|
||||
//(got an inheritance security rules violated by type error)
|
||||
[assembly: System.Security.SecurityRules(System.Security.SecurityRuleSet.Level1)]
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
[assembly: log4net.Config.XmlConfigurator(Watch = true)]
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("A87ADD48-9DB5-4068-BCC6-377CC54E7AE4")]
|
||||
|
||||
//[assembly: System.Security.SecurityRules(System.Security.SecurityRuleSet.Level1)]
|
||||
|
||||
[assembly: log4net.Config.XmlConfigurator(Watch = false)]
|
||||
@@ -258,6 +258,7 @@
|
||||
<Compile Include="..\SolutionInfo.cs">
|
||||
<Link>Properties\SolutionInfo.cs</Link>
|
||||
</Compile>
|
||||
<Content Include="App_Code\TestClass.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Content Include="config\splashes\booting.aspx" />
|
||||
<Content Include="config\splashes\noNodes.aspx" />
|
||||
@@ -1813,7 +1814,6 @@
|
||||
</None>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="App_Code\" />
|
||||
<Folder Include="App_Data\" />
|
||||
<Folder Include="css\" />
|
||||
<Folder Include="macroScripts\" />
|
||||
|
||||
@@ -22,4 +22,4 @@
|
||||
<conversionPattern value="%date [%thread] %-5level %logger - %message%newline" />
|
||||
</layout>
|
||||
</appender>
|
||||
</log4net>
|
||||
</log4net>
|
||||
@@ -1,6 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<configSections >
|
||||
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" requirePermission="false" />
|
||||
|
||||
<section name="urlrewritingnet" restartOnExternalChanges="true" requirePermission="false" type="UrlRewritingNet.Configuration.UrlRewriteSection, UrlRewritingNet.UrlRewriter" />
|
||||
<section name="microsoft.scripting" type="Microsoft.Scripting.Hosting.Configuration.Section, Microsoft.Scripting, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" />
|
||||
|
||||
@@ -19,6 +21,9 @@
|
||||
</sectionGroup>
|
||||
<!-- End of added in Umbraco 4.6.2 -->
|
||||
</configSections>
|
||||
|
||||
<log4net configSource="config\log4net.config" />
|
||||
|
||||
<urlrewritingnet configSource="config\UrlRewriting.config" />
|
||||
<microsoft.scripting configSource="config\scripting.config" />
|
||||
<clientDependency configSource="config\ClientDependency.config" />
|
||||
@@ -73,6 +78,7 @@
|
||||
<!--<add name="LocalSqlServer" connectionString="server=.\sqlexpress;database=aspnetdb;user id=DBUSER;password=DBPASSWORD" providerName="System.Data.SqlClient"/>-->
|
||||
</connectionStrings>
|
||||
<system.web>
|
||||
<trust level="Medium"/>
|
||||
<customErrors mode="RemoteOnly" />
|
||||
<trace enabled="true" requestLimit="10" pageOutput="false" traceMode="SortByTime" localOnly="true" />
|
||||
<sessionState mode="InProc" stateConnectionString="tcpip=127.0.0.1:42424" sqlConnectionString="data source=127.0.0.1;Trusted_Connection=yes" cookieless="false" timeout="20" />
|
||||
|
||||
@@ -1,5 +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
|
||||
@@ -11,8 +13,18 @@ using System.Runtime.CompilerServices;
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyProduct("")]
|
||||
|
||||
//tg forcing .NET 2.0 security rules, since otherwise it wasn't possible to run in medium trust
|
||||
//(got an inheritance security rules violated by type error)
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("ce9d3539-299e-40d3-b605-42ac423e24fa")]
|
||||
|
||||
//This is required so that Medium trust works and this is because of this class:
|
||||
// umbraco.presentation.templateControls.ItemDesigner since this class cannot inherit from
|
||||
// the System.Web.UI.Design.ControlDesigner in partial trust (or something along those lines)
|
||||
// if we remove this class then we won't need to do this.
|
||||
[assembly: System.Security.SecurityRules(System.Security.SecurityRuleSet.Level1)]
|
||||
|
||||
[assembly: InternalsVisibleTo("Umbraco.Tests")]
|
||||
[assembly: InternalsVisibleTo("Umbraco.Tests")]
|
||||
@@ -11,7 +11,7 @@ namespace umbraco.presentation.templateControls
|
||||
/// This control disables request validation (equalevant of setting validateRequest to false in page directive)
|
||||
/// </summary>
|
||||
[ToolboxData("<{0}:DisableRequestValidation runat=\"server\"></{0}:Item>")]
|
||||
[Designer(typeof(ItemDesigner))]
|
||||
[Designer("umbraco.presentation.templateControls.ItemDesigner, umbraco")]
|
||||
public class DisableRequestValidation : System.Web.UI.WebControls.WebControl
|
||||
{
|
||||
protected override void OnInit(EventArgs e)
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.ComponentModel;
|
||||
using System.Security;
|
||||
using System.Security.Permissions;
|
||||
using System.Web;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
@@ -14,7 +16,7 @@ namespace umbraco.presentation.templateControls
|
||||
/// </summary>
|
||||
[DefaultProperty("Field")]
|
||||
[ToolboxData("<{0}:Item runat=\"server\"></{0}:Item>")]
|
||||
[Designer(typeof(ItemDesigner))]
|
||||
[Designer("umbraco.presentation.templateControls.ItemDesigner, umbraco")]
|
||||
public class Item : CompositeControl
|
||||
{
|
||||
#region Private Fields
|
||||
|
||||
0
src/packages/log4net.2.0.0/lib/net40-full/custom-build-readme.txt
vendored
Normal file
0
src/packages/log4net.2.0.0/lib/net40-full/custom-build-readme.txt
vendored
Normal file
Binary file not shown.
48226
src/packages/log4net.2.0.0/lib/net40-full/log4net.xml
vendored
48226
src/packages/log4net.2.0.0/lib/net40-full/log4net.xml
vendored
File diff suppressed because it is too large
Load Diff
@@ -186,14 +186,14 @@
|
||||
<Project>{511F6D8D-7717-440A-9A57-A507E9A8B27F}</Project>
|
||||
<Name>umbraco.interfaces</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\src\Umbraco.Web\Umbraco.Web.csproj">
|
||||
<Project>{651E1350-91B6-44B7-BD60-7207006D7003}</Project>
|
||||
<Name>umbraco.presentation</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\src\umbraco.providers\umbraco.providers.csproj">
|
||||
<Project>{D7636876-0756-43CB-A192-138C6F0D5E42}</Project>
|
||||
<Name>umbraco.providers</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\src\Umbraco.Web\Umbraco.Web.csproj">
|
||||
<Project>{651E1350-91B6-44B7-BD60-7207006D7003}</Project>
|
||||
<Name>Umbraco.Web</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<BootstrapperPackage Include=".NETFramework,Version=v4.0">
|
||||
|
||||
Reference in New Issue
Block a user