Grasshopper

algorithmic modeling for Rhino

I have a  foo.dll assembly compiled with IronPython. I can reference it in a VS project, together with all IronPython libs required to run the pythonesque library... 

Imports IronPython.Hosting
Imports IronPython.Runtime
Imports IronPython
Imports Microsoft.Scripting.Hosting
Imports Microsoft.Scripting
Imports System.IO
Imports System.Reflection

Public Class Form1

Private Sub Form_Load(sender As Object, e As EventArgs) Handles MyBase.Load

End Sub

Private Sub Form_Click() Handles Me.Click

Dim engine As Microsoft.Scripting.Hosting.ScriptEngine = Python.CreateEngine()
Dim fooPath = Path.GetFullPath("foo.dll")
Dim fooAms = Assembly.LoadFile(fooPath)

engine.Runtime.LoadAssembly(fooAms)

Dim obj As Object = engine.ImportModule("foo")

MsgBox(foo.foo)

End Sub

End Class

As you can see, it is a simple windows form, which clicked should load the foo.dll, and then display a msgbox with "Foo" (the foo function in the foo.dll assembly returns "foo" string). When I run the program, it crashes at the bold line with error :

An unhandled exception of type 'System.Reflection.TargetInvocationException' occurred in mscorlib.dll

Additional information: Exception has been thrown by the target of an invocation.

Any ideas how to solve this problem (looking at you python ppl) ?

EDIT : The fooPath is ok, and it properly shows the fooAms' version and other properties.

Views: 497

Replies to This Discussion

Can be anything. Did you check for the innerexception? Just make sure to catch your exception and print the StackTrace property of the exception. See also: http://www.homeandlearn.co.uk/NET/nets5p4.html

At this point I can't see where you define the object foo. Should that be obj.foo? 

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service