正在Reflection.net中获取MethodMissingException
本文关键字:获取 MethodMissingException net Reflection 正在 | 更新日期: 2023-09-27 17:59:15
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Processor
{
public class InvoiceProcessorTest
{
public void Process(String entity)
{
GenerateInvoice generateInvoice = new GenerateInvoice();
generateInvoice.Process(entity);
}
public string ProcessTest(String str)
{
return "testString";
}
}
}
我的代码读取方法是
Assembly processorAssembly = Assembly.LoadFile("ProjectDLL.dll");
AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve);
Type myType= processorAssembly.GetType("Processor.InvoiceProcessorTest");
object myObj = Activator.CreateInstance(myType);
Console.WriteLine((string)myType.InvokeMember("ProcessTest", BindingFlags.InvokeMethod | BindingFlags.Instance | BindingFlags.Public, null, myObj , new object[] { "Pramod" }));
我想调用InvoiceProcessorTest类的ProcessTest方法。
myType.GetMethods()
向我展示了类中的两个方法。
但是当我调用成员时,它返回一个缺少的MethodException。命名空间。InvoiceProcessor测试。找不到ProcessTest
尝试
Console.WriteLine((string)myType.InvokeMember(.........
使用mytype。调用成员