2016-02-23 39 views
0

我有我的declation一個問題,當我使用invoke方法作爲一個MethodInfo類型:Invoke方法動態地在VB.Net SAP Business One的

錯誤消息:

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> 

回答

0

我不是VB中的反射專家,但你確定_StepInfo.CurrObj已經被初始化並且不爲空?你需要一個有效的對象初始化實例來使用Invoke,否則你可能會得到一個空引用異常。

編輯: 另外,它可能有助於查看初始化_StepInfo.CurrObj,_MethodToRun和_MemberAccess的代碼。

+1

你好,新版本的SAP Business One 9.2有一個限制許可,我們不能使用反射。 –

+0

很高興知道。謝謝! – Overhed

相關問題