【问题标题】:mono - how to use ref with CreateInstance or InvokeMethod?mono - 如何将 ref 与 CreateInstance 或 InvokeMethod 一起使用?
【发布时间】:2013-02-01 02:45:52
【问题描述】:

如何在 Mono 中使用 CreateInstance 传递“ref”?

例子:

public MyMethod(ref SomeType data) {...
...
SomeType st = new SomeType();
object handle = Activator.CreateInstance(type, new object[] { st });

这在我的 Windows 控制台应用程序中运行良好。问题是当我将它移植到 Mono 时,我得到一个缺少方法异常,指出没有找到接受类型“SomeType”的“MyMethod”。

如果我从构造函数中删除 'ref',Mono 会找到该方法并运行它而没有任何问题。

有什么想法吗?

提前致谢。

【问题讨论】:

标签: mono out ref createinstance invokemember


【解决方案1】:

这是 Mono 2.6 版之前的问题。修复地址通过 ref 传递给 CreateInstance。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-06-07
    • 2021-08-21
    • 1970-01-01
    • 1970-01-01
    • 2010-11-01
    • 2018-06-12
    相关资源
    最近更新 更多