Ich versuche this example of calling IronPython Code von VB.net zu replizieren. Ich habe IronPython heruntergeladen und installiert und eine VB.net-Konsolenanwendung erstellt. Ich habe Verweise auf alle DLLs in der Ironpython-Installationsordner:Aufruf von IronPython über VB.net - "Name 'PythonEngine' wird nicht deklariert."
- Ironpython
- IronPython.Modules
- IronPythonTest
- Microsoft.Scripting.ExtensionAttribute
- Microsoft.Scripting
- Microsoft. Scripting.Core
Und ich habe th ist Quellcode:
Option Explicit On
Option Strict On
Imports Microsoft.Scripting.Hosting
Imports Microsoft.Scripting
Imports IronPython.Hosting
Imports IronPython.Runtime.Types
Module Module1
Public Class HelloWorldVB
Public Overridable Function HelloWorld(ByVal name As String) As String
Return String.Format("Hello '{0}' from Visual Basic", name)
End Function
End Class
Sub Main()
Dim helloWorld As New HelloWorldVB()
Console.WriteLine(helloWorld.HelloWorld("Maurice"))
Dim runtime As ScriptRuntime = PythonEngine.CurrentEngine.Runtime
Dim scope As ScriptScope = Runtime.ExecuteFile("HelloWorld.py")
Dim pythonType As PythonType = scope.GetVariable(Of PythonType)("HelloWorldIronPython")
helloWorld = CType(Runtime.Operations.Call(pythonType), HelloWorldVB)
Console.WriteLine(helloWorld.HelloWorld("Maurice"))
Console.ReadLine()
End Sub
End Module
Ich erhalte den Fehler "Name 'PythonEngine' wird nicht deklariert."
Ich kann PythonEngine nicht finden, wenn ich den ObjectBrowser suche.
Ist das Beispiel veraltet oder habe ich einen Fehler?