2
나는 dll을 작성하려고 시도하고 콘솔 프로그램에서 부분적으로 아래 코드를 호출합니다. 그러나 어떻게 든 getinterface가 항상 null을 반환하고 그 다음에 함수를 호출 할 수없는 이유가 없습니다. dll.GetInterface는 항상 null을 반환합니다.
MyDLL.dll
namespace mynamespace
{
public interface IMyClass
{
void test();
}
public class MyClass : IMyClass
{
public void test()
{
// Do Something here
}
}
}
앱은 : t.GetInterface("mynamespace.IMyClass")
는 항상 null을 반환하는 이유
class Program
{
static void Main(string[] args)
{
List<object> output = new List<object>();
Assembly assembly = Assembly.LoadFile(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "MyDLL.dll"));
foreach (Type t in assembly.GetTypes())
{
if (t.IsClass && !t.IsAbstract && t.GetInterface("mynamespace.IMyClass") != null)
{
output.Add(Activator.CreateInstance(t));
}
}
Console.WriteLine("Log is written successfully. Press any key to exit");
Console.Read();
}
}
모르겠어요?