2017-08-04 31 views
0

我想创建一个保存方法MAILMESSAGE,它抛出下面的错误:“System.Reflection.TargetParameterCountException”,而MAILMESSAGE调用方法mailwriter

An unhandled exception of type 'System.Reflection.TargetParameterCountException' occurred in mscorlib.dll Additional information: Parameter count mismatch.

下面是覆盖方法:

_sendMethod.Invoke(
    Message, 
    BindingFlags.Instance | BindingFlags.NonPublic, 
    null, 
    new object[] { _mailWriter, true }, 
    null); 

回答

0

扩展方法不支持.NET framework 4.5以上版本。 因此会出现参数计数异常..在.NET Framework 4.0中,相同的扩展方法工作正常。