-
Notifications
You must be signed in to change notification settings - Fork 748
Error with Enum GCHandleType.Pinned #174
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 show exactly what And yes, C# enums are integers. |
I have the following: print(type(CSArray))
>>><class 'System.Byte[]'> Using your definition gives the same error on my computer. On my side, for test purpose, I create public static byte[] Test_Image()
{
Image image = Image.FromFile("C:\\users\\alex\\logo.png");
ImageConverter converter = new ImageConverter();
byte[] byteArray = (byte[]) converter.ConvertTo(image, typeof(byte[]));
return byteArray;
} |
What versions of Python, Python.NET and .NET are you using? |
Sorry I forgot: |
from System import Int32
handler = GCHandle.Alloc(CSArray, Int32(GCHandleType.Pinned)) Gives me the same error as before.... What a pity! |
@aPere3 all tests have been passed, so please try this updated version! |
@denfromufa , I cloned an build from the master branch since you merged it a few hours ago... |
@aPere3 this used to work before, because overloading did not really check for types, which was giving wrong results like In your case what happens is that .NET enum So the temporary fix would be one of the following:
But the bigger problem is that why Let me know what you think @tonyroberts @filmor ? |
@denfromufa was your last post dedicated to me or developers of pythonNet? Because I'm quite new to python and I didn't get the details of your temporary fix recipe. Anyway, is a downgrading to another version of python likely to help me with this bug ? |
@aPere3 did my patch work for you? if yes, then can you close this issue? |
@denfromufa Sorry for the late reply...
an error occurs. I didn't notice it because the files are built anyway but I have:
Is it important? Why are the files built anyway? |
As you can see from pull request #176 it has not been merged yet, so you need to https://github.com/denfromufa/pythonnet/tree/patch-8 Not sure about ildasm.exe, which .net versions do you have installed? On Friday, March 11, 2016, Alex, Péré <notifications@github.com
|
@denfromufa re your question about IronPython, PythonNet has nothing to do with IronPython - they are no way related. Any similarity is purely because they are both related to Python, not with each other. IronPython is a Python language implementation for the CLR, whereas PythonNet is a set of libraries built using the CPython API. Questions about why one has diverged from the other are irrelevant as neither is derived from the other. |
@denfromufa Sorry for (very) late reply. I tried with your patch branch, and no error occurred on the line. This seems to have worked! Thank you very much! Anyway my code still do not work, but it is not related to this bug anymore, haha! |
@tonyroberts I thought ironpython compatibility is one of goals in pythonnet, because some people switch from ironpython due to obvious reasons, unless pythonnet breaks their existing ironpython code without migration path. @aPere3 glad to know that this works, open another issue if your new issue is related to pythonnet. |
Thank you I close! |
Hello,
I try to use the following snippet from this page to turn a
byte[]
into a numpy array:On this line:
I get the following error:
TypeError: No method matches given arguments
Executing this code:
brings no error, so I assume that the issue must be from
GCHandleType.Pinned
.I'm a bit troubled by:
Is it normal that
enum
are modeled byint
?Anyway, I can't get to have my code working...
The text was updated successfully, but these errors were encountered: