リフレクションを使用してオブジェクトのインスタンスを作成し、オブジェクトのクラス内でメソッドを取得していますが、Type
あいまいさの問題を回避するために型の配列を使用する必要がある場合に問題が発生します。到達しようとしています。
public class BigClass
{
public void getSomething(XmlDocument doc, ref CustomObject obj) {...}
public void getSomething(XmlDocument doc, ref CustomObject obj, string id) {...}
}
このコードは外部アセンブリ (file.dll) からのもので、次のコードを使用しています。
Assembly a = Assembly.LoadFrom("file.dll");
Type s = a.GetType("FileNamespace.BigClass");
MethodInfo inf = s.GetMethod("getSomething", new [] {typeof(XmlDocument), typeof(CustomObject), typeof(string)});
3つの引数を使用するオブジェクトの を取得するのにMethodInfo
、変数 inf が null になるのは、ref を使用する引数のメソッドが見つからないためだと思います。
これを解決する方法はありますか?