Content-Length: 292933 | pFad | https://github.com/pythonnet/pythonnet/issues/492

A6 Error when exposing a python method to .Net in python 2. · Issue #492 · pythonnet/pythonnet · GitHub
Skip to content

Error when exposing a python method to .Net in python 2. #492

@klasma

Description

@klasma

Environment

  • Pythonnet version: 2.3.0
  • Python version: 2.7.13
  • Operating System: Windows 10

Details

We are trying to expose a python method in .Net, in a class that inherits from System.Object.

We are following the example code in clr.py in the pythonnet repository except that we are inheriting from System.Object and that we are using a namespace. When we run

class X(System.Object):
    __namespace__ = "PyTest"
    @clrmethod(int, [str])
    def test(self, x):
        return len(x)

we get the error message

Traceback (most recent call last):
File "test.py", line 80, in
class X(System.Object):
TypeError: Error when calling the metaclass bases
Unable to find an entry point named 'PyIter_Check' in DLL 'python27'.

The error seems to be due to the fact that PyIter_Check is a #define statement and not a function in python. Therefore the import of the function fails in runtime.cs. The error does not occur in python 3 because PyIter_Check is not imported when python 3 is used.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions









      ApplySandwichStrip

      pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


      --- a PPN by Garber Painting Akron. With Image Size Reduction included!

      Fetched URL: https://github.com/pythonnet/pythonnet/issues/492

      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy