Hi Curt,
Thanks for replying. When I view the link I see the following:
The .NET code creates the "Test" class and then runs the python code
which imports the "Test" class a subclasses it to create python class
"X".
Class "X" is then called and cast to type "Test" and assigned to the
value obj.
Is this what you are looking at?
My code is pretty much identical. The VB looks like:
Public MustInherit Class ChildControl
Public Function Control() As WebControl
Return Nothing
End Function
Public Function GetValue() As String
Return Nothing
End Function
Public Function SetValue(ByVal value As Object) As String
Return Nothing
End Function
End Class
Class IPReflection
Private Shared Instance As IPReflection = Nothing
Private PyEngine As PythonEngine
Private PyModule As EngineModule
Public Shared Function Inst() As IPReflection
If Instance Is Nothing Then
Instance = New IPReflection
End If
Return Instance
End Function
Private Sub New()
Dim path As String = HttpContext.Current.Request.MapPath(".")
PyEngine = New PythonEngine
PyEngine.AddToPath(path)
PyModule = PyEngine.CreateModule
PyEngine.DefaultModule = PyModule
PyEngine.ExecuteFile(HttpContext.Current.Request.MapPath("CustomControls
.py"))
End Sub
Public Function GetChildControl() As ChildControl
Return
CType(Operations.Ops.Call(PyModule.Globals("GetControl")), ChildControl)
End Function
End Class
And the python looks like:
import clr
import sys
clr.AddReference('System')
import System
sys.path.append(sys.path[0] + "/bin")
clr.AddReferenceToFile("WebControlLibrary.dll")
clr.AddReference('System.Web')
from System.Web.UI.WebControls import Label
from WebControlLibrary import ChildControl
class LabelChildControl(ChildControl):
def __init__(self):
self.control = Label()
def Control(self):
return self.control
def GetControl():
return LabelChildControl()
Thanks again,
Kyle
________________________________
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Curt
Hagenlocher
Sent: Friday, 22 February 2008 3:08 PM
To: Discussion of IronPython
Subject: Re: [IronPython] returning inherited classes to .NET
The page in question doesn't seem to show what you describe -- deriving
a Python class from a C# class. Maybe you could show us your sample
code?
On Thu, Feb 21, 2008 at 7:39 PM, Howland-Rose, Kyle
<[EMAIL PROTECTED]> wrote:
Hi all,
I am following
http://www.ironpython.info/index.php/Using_Python_Classes_from_.NET
<http://www.ironpython.info/index.php/Using_Python_Classes_from_.NET>
but using VB.
In VB I declare a class and derive a python 1.1 class from it
but when I return it I get the exception:
"Unable to cast object of type
'IronPython.NewTypes.WebControlLibrary.ChildControl_1' to type
'WebControlLibrary.ChildControl'."
The page referenced above just seems to cast the python class
instance to the C# class instance but this does not work for me in VB.
Any help would be appreciated :)
Thanks,
Kyle
************************************************************************
Allens Arthur Robinson online: http://www.aar.com.au
<http://www.aar.com.au/>
This email is confidential and may be subject to legal or other
professional privilege. It is also subject to copyright. If you have
received it in error, confidentiality and privilege are not waived and
you must not disclose or use the information in it. Please notify the
sender by return email and delete it from your system. Any personal
information in this email must be handled in accordance with the Privacy
Act 1988 (Cth).
************************************************************************
*
************************************************************************
Allens Arthur Robinson online: http://www.aar.com.au
<http://www.aar.com.au/>
This email is confidential and may be subject to legal or other
professional privilege. It is also subject to copyright. If you have
received it in error, confidentiality and privilege are not waived and
you must not disclose or use the information in it. Please notify the
sender by return email and delete it from your system. Any personal
information in this email must be handled in accordance with the Privacy
Act 1988 (Cth).
************************************************************************
*
_______________________________________________
Users mailing list
[email protected]
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
_______________________________________________
Users mailing list
[email protected]
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
************************************************************************
Allens Arthur Robinson online: http://www.aar.com.au
This email is confidential and may be subject to legal or other professional
privilege. It is also subject to copyright. If you have received it in error,
confidentiality and privilege are not waived and you must not disclose or use
the information in it. Please notify the sender by return email and delete it
from your system. Any personal information in this email must be handled in
accordance with the Privacy Act 1988 (Cth).
*************************************************************************
_______________________________________________
Users mailing list
[email protected]
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
_______________________________________________
Users mailing list
[email protected]
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com