从C#程序通过.dll调用VB.NET方法

时间:2014-10-28 11:26:36

标签: c# vb.net

我的代码包含一个VB.Net类,我已经内置到.dll中,将在C#-WPF程序中使用,问题是当我尝试从该.dll调用任何函数时,我得到一个错误说:

  

这种方法有一些无效的论证

我的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有一些无效的论点

1 个答案:

答案 0 :(得分:1)

我认为你不喜欢用out参数调用方法,因为VB.net不支持它们。尝试将其称为:

SwitchControl.PerformDCVoltageMeasurement_niDMM(ref Jg);