-
-
Save DavidKarlas/7e263d4ae4ff5d6333b6 to your computer and use it in GitHub Desktop.
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
using System; | |
using System.Reflection; | |
using System.Security.Policy; | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
AppDomainSetup domaininfo = new AppDomainSetup(); | |
domaininfo.ApplicationBase = System.Environment.CurrentDirectory; | |
Evidence adevidence = AppDomain.CurrentDomain.Evidence; | |
AppDomain domain = AppDomain.CreateDomain("MyDomain", adevidence, domaininfo); | |
Type type = typeof(Proxy); | |
var value = (Proxy)domain.CreateInstanceAndUnwrap( | |
type.Assembly.FullName, | |
type.FullName); | |
var assembly = value.GetAssembly("C:\\Users\\David\\Documents\\Projects\\cpp534534526423463\\cpp534534526423463\\bin\\Debug\\lib2.dll"); | |
var lal = assembly.GetTypes () [0]; | |
var instance = Activator.CreateInstance (lal); | |
// AppDomain.Unload(domain); | |
} | |
} | |
public class Proxy : MarshalByRefObject | |
{ | |
public Assembly GetAssembly(string assemblyPath) | |
{ | |
try | |
{ | |
return Assembly.LoadFile(assemblyPath); | |
} | |
catch (Exception) | |
{ | |
return null; | |
// throw new InvalidOperationException(ex); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment