I have my DLL:
using System;
namespace DLLtest
{
public static class TestDll
{
public static void TestVoid()
{
Console.WriteLine("TestVoid called");
}
}
}
and in my program I'm doing:
Assembly a = Assembly.LoadFile(
Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "DLLtest.dll"));
var b = a.GetType("TestDll").GetMethod("TestVoid");
b.Invoke(null, new object[] { });
And I get NullReferenceException
on "var b...
" line (indeed something is null as What is a NullReferenceException, and how do I fix it? explains, but assembly is loaded and class should be there).
I tried adding BindingFlags, but always the same error...