VB.net 2010 视频教程 VB.net 2010 视频教程 python基础视频教程
SQL Server 2008 视频教程 c#入门经典教程 Visual Basic从门到精通视频教程
当前位置:
首页 > VB.net教程 >
  • vbnet和python,从vb.net运行Python函数 最新发布

I am new with vb.net. I am trying to call python functions from vb.net but getting error that 'Invoke' is not a member of 'Microsoft.Scripting.Hosting.ObjectOperations'

Imports Microsoft.Scripting

Imports Microsoft.Scripting.Hosting

Imports IronPython.Hosting

Sub Main

Dim engine As ScriptEngine

Dim scope As ScriptScope

Dim i As Integer

engine = Python.CreateEngine()

scope = engine.ExecuteFile("C:\Working.py")

Dim v = engine.Operations.Invoke(scope.GetVariable(methodName))

' name of the method thaT NEEDS TO INVOKED AND GET THE RETURN VALUE.

Can anyone please recommend me better way to make this work? I have already seen this link :http://msmvps.com/blogs/theproblemsolver/archive/2008/08/14/calling-ironpython-functions-from-net.aspx

Thank you in advance.

解决方案

Something like the following should work:

Sub Main(ByVal args() As String)

Dim pyRT As ScriptRuntime = Python.CreateRuntime()

Dim workingObj As Object = pyRT.UseFile("working.py")

workingObj.methodName()

End Sub

出处:https://blog.csdn.net/weixin_33737261/article/details/118819278?spm=1001.2101.3001.6650.1&utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7ECTRLIST%7ERate-1.pc_relevant_default&depth_1-utm_source=distribute.pc_relevant.none-task-blog-2%7Edefault%7ECTRLIST%7ERate-1.pc_relevant_default&utm_relevant_index=2
 


相关教程