2014-10-28 38 views
-2

我的代碼包含一個VB.Net類,我已經內置到將在C#-WPF程序中使用的.dll中,問題是當我嘗試調用任何從.dll文件功能我得到一個錯誤說:從C#程序通過.dll調用VB.NET方法

的梅索德有一些invalide參數

我的VB代碼:

Public Function PerformDCVoltageMeasurement_niDMM(ByRef dDMM_Reading As Double) As Boolean 
    Try 

     Call Initialize_niDMM(GetInstrumentAddress(sPXIInstrument).DeviceAddress, DC_VOLTS, 60, 100, 3.5) 
     Dim dTemp As Double 
     'Start the acquisition 
     NIpxiDMM.Initiate() 
     NIpxiDMM.Fetch(-1, dTemp) 
     dDMM_Reading = dTemp 
     NIpxiDMM.Dispose() 
     Return True 

    Catch 
     gsCurrentPXIDeviceAddress_dmm = "" 
     NIpxiDMM.Dispose() 
     Return False 
    End Try 
End Function 

和我的C#代碼-wpf:

SwitchExecutive.SwitchExecutive SwitchControl = new SwitchExecutive.SwitchExecutive(); 
Double Jg; 
SwitchControl.PerformDCVoltageMeasurement_niDMM(out Jg); 

最後一條語句給出錯誤

了Methode有一些無效的參數

+2

'ByRef'是c#中的'ref',而不是'out'。 – 2014-10-28 11:28:59

+1

看看智能感知系統,它將向您顯示正確的方法簽名,或在網絡中搜索** exact **編譯器錯誤。 – CodeCaster 2014-10-28 11:31:11

回答

1

我認爲它不喜歡你的呼喚與out參數的方法,因爲VB.net不支持他們。嘗試將其稱爲:

SwitchControl.PerformDCVoltageMeasurement_niDMM(ref Jg); 
+0

謝謝Anduril,它解決了我的問題^^ – user2933082 2014-10-28 11:58:45