-
Notifications
You must be signed in to change notification settings - Fork 748
.NET OBject type error "value cannot be converted to Object" #94
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
can you treat sys as Dynamic object? |
I don't understand the question! This is all in Python code, not C#. |
@denfromufa I think you've missed the point somewhat. When passing a Python object to a managed call it is converted to a managed object (eg a python float is converted to a managed Double). If you were writing managed code you could use a dynamic type to refer to the instance of the converted object, but that doesn't help in this case as there is no conversion available from the python object to a managed object in the first place. A possible solution would be to change Converter::ToManagedValue (in converter.cs) to fallback to convert all Python objects without a reasonable conversion to a native managed type to a PyObject managed type. This looks simple enough, but there are a couple of issues that would need to be considered:
Both of these problems can be resolved, but I just wanted to point them out as it's not a simple as going in and fixing ToManagedValue. |
@tonyroberts, @andygraham good point on Dynamic. Regarding keeping PyObject in .NET, would that require pinning unmanaged Python object and later manually releasing the handle? |
Another thing I don't understand is why the following mechanism cannot be On Wed, Sep 2, 2015, 3:33 AM Tony Roberts notifications@github.com wrote:
|
This is fixed. |
Using Cpython 2.7.10 and pythonnet-2.1.0.dev1
I may be missing something as I am an IronPython user just playing to see if my Windows Forms code can run on CPython and PythonNet.
To fully use Windows Forms with PythonNet it is convenient, even necessary at times, to treat any Python object as a .NET Object so that it can be passed as a parameter to a delegate. For example to invoke a Python function to run on a WinForms GUI thread from a different thread you need to use Control.BeginInvoke which takes an Object array for the method parameters. There is no need to access these objects from .NET code, merely to package and unpackage them as .NET Object types which IronPython has no trouble doing. An example of this failure
I was actually interested in passing frame objects which have the same problem.
The text was updated successfully, but these errors were encountered: