[NUnit.Framework.Test]
public void Test2()
{
var _context = Spring.Context.Support.ContextRegistry.GetContext();
var instance = _context.GetObject("SchoolDao"); object proxy = _context.GetObject("SchoolProxy");
Spring.Aop.Framework.ProxyFactory factory = new Spring.Aop.Framework.ProxyFactory(instance);
factory.AddAdvice((AopAlliance.Intercept.IMethodInterceptor)proxy);
instance = factory.GetProxy(); object objValue = instance.GetType().InvokeMember(
"Get",
System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.InvokeMethod,
null,
instance,
new object[] { "123" }
);
}出错提示:该方法的参数和签名不匹配。如果不加上代理的话就没有问题谢谢
这句报错吗
Test 'Z.Shop.Test.Test.DataTest.Test2' failed: System.BadImageFormatException : 该方法的参数和签名不匹配。
在 System.Reflection.RuntimeParameterInfo.GetParameters(IRuntimeMethodInfo methodHandle, MemberInfo member, Signature sig, ParameterInfo& returnParameter, Boolean fetchReturnParameter)
在 System.Reflection.RuntimeMethodInfo.FetchNonReturnParameters()
在 System.Reflection.RuntimeMethodInfo.GetParametersNoCopy()
在 System.RuntimeType.FilterApplyMethodBase(MethodBase methodBase, BindingFlags methodFlags, BindingFlags bindingFlags, CallingConventions callConv, Type[] argumentTypes)
在 System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams)
在 System.Type.InvokeMember(String name, BindingFlags invokeAttr, Binder binder, Object target, Object[] args)
Test\DataTest.cs(56,0): 在 Z.Shop.Test.Test.DataTest.Test2()