Skip to content

Instantly share code, notes, and snippets.

@lolp1
Last active July 30, 2017 20:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lolp1/9137ebe71970900fd003e738e03f3b4a to your computer and use it in GitHub Desktop.
Save lolp1/9137ebe71970900fd003e738e03f3b4a to your computer and use it in GitHub Desktop.
public void LoadAndRun(string file)
{
var asm = Assembly.Load(file);
var DLL_MAIN =
asm
.GetTypes()
.SelectMany(type => type.GetMethods())
.First(methodInfo =>
{
var invariant = methodInfo.Name.ToLowerInvariant();
return invariant == dll_main;
});
if (DLL_MAIN == null)
{
throw new ArgumentNullException(nameof(DLL_MAIN));
}
DLL_MAIN.Invoke(null, null);
}
[DllExport("InitializeMyApp")]
public static void Initialize_MyApp()
{
Initialize();
}
private static void Initialize()
{
// .
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment