-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
NugetAssemblyLocator load file in same assembly context (like ModuleF…
…inder does)
- Loading branch information
Showing
5 changed files
with
34 additions
and
19 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,30 @@ | ||
using System; | ||
using System.Reflection; | ||
|
||
namespace KY.Core | ||
{ | ||
public static class AssemblyHelper | ||
{ | ||
public static Assembly LoadInSameContext(string path) | ||
{ | ||
Type loaderType = Type.GetType("System.Runtime.Loader.AssemblyLoadContext"); | ||
if (loaderType != null) | ||
{ | ||
PropertyInfo defaultProperty = loaderType.GetProperty("Default", BindingFlags.Static | BindingFlags.Public); | ||
if (defaultProperty != null && defaultProperty.CanRead) | ||
{ | ||
object defaultContext = defaultProperty.GetMethod.Invoke(null, new object[0]); | ||
if (defaultContext != null) | ||
{ | ||
MethodInfo loadMethod = defaultContext.GetType().GetMethod("LoadFromAssemblyPath"); | ||
if (loadMethod != null) | ||
{ | ||
return (Assembly)loadMethod.Invoke(defaultContext, new object[] { path }); | ||
} | ||
} | ||
} | ||
} | ||
return Assembly.LoadFrom(path); | ||
} | ||
} | ||
} |
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
1 change: 1 addition & 0 deletions
1
Core.Common.Standard/KY.Core.Common.Standard.csproj.DotSettings
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 |
---|---|---|
@@ -1,2 +1,3 @@ | ||
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation"> | ||
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=helpers/@EntryIndexedValue">True</s:Boolean> | ||
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=nuget/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary> |
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
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