0

メソッドの呼び出しを MethodInfo 型として使用すると、宣言に問題があります。

エラーメッセージ:

object reference not set to an instance of an object.
Dim oMethod As MethodInfo 
oMethod = _StepInfo.CurrSysType.GetMethod(Me._MethodToRun, _MemberAccess)
'calling method on object by reflection
Dim dStart As DateTime = DateTime.Now
Dim iRes As Integer = 0
iRes = CInt(oMethod.Invoke(_StepInfo.CurrObj, Nothing)) 
Dim dEnd As DateTime = DateTime.Now
System.Diagnostics.Debug.WriteLine("Processing Object: " & (dEnd - dStart).TotalMilliseconds) </i>
4

1 に答える 1

0

私は VB のリフレクションの専門家ではありませんが、_StepInfo.CurrObj が初期化されており、null でないことは確かですか? Invoke を使用するには、オブジェクトの有効な初期化済みインスタンスが必要です。そうしないと、取得しているような null 参照例外が発生する可能性があります。

編集: また、_StepInfo.CurrObj、_MethodToRun、および _MemberAccess を初期化するコードを確認すると役立つ場合があります。

于 2016-02-24T13:45:50.763 に答える