-
Notifications
You must be signed in to change notification settings - Fork 107
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed the issue of temporary ASP.NET assemblies not being resolved co…
…rrectly
- Loading branch information
Showing
2 changed files
with
41 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
using System; | ||
using System.Linq; | ||
using System.Reflection; | ||
using Composite.Core; | ||
using Composite.Core.Application; | ||
|
||
namespace Composite.AspNet | ||
{ | ||
/// <summary> | ||
/// Fixed the issue of temporary asp.net assemblies not being resolved correctly. | ||
/// </summary> | ||
[ApplicationStartup] | ||
class TempAssembliesFix | ||
{ | ||
public static void OnInitialized() | ||
{ | ||
AppDomain.CurrentDomain.AssemblyResolve += CurrentDomainOnAssemblyResolve; | ||
} | ||
|
||
private static Assembly CurrentDomainOnAssemblyResolve(object sender, ResolveEventArgs args) | ||
{ | ||
string asmName = args.Name; | ||
|
||
if (!asmName.StartsWith("App_") || !asmName.Contains(",")) | ||
{ | ||
return null; | ||
} | ||
|
||
var assembly = AppDomain.CurrentDomain.GetAssemblies().FirstOrDefault(asm => asm.FullName == asmName); | ||
if (assembly != null) | ||
{ | ||
return assembly; | ||
} | ||
|
||
Log.LogVerbose("OnAssemblyResolve", $"Failed to resolve assembly: {args.Name}" | ||
+ (args.RequestingAssembly != null ? $", requesting assembly: '{args.RequestingAssembly.FullName}'" : "")); | ||
return null; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters