Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/350.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vb.net/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
VB dll在带有ctypes的python中不起作用(未找到函数*)_Python_Vb.net_Dll_Ctypes - Fatal编程技术网

VB dll在带有ctypes的python中不起作用(未找到函数*)

VB dll在带有ctypes的python中不起作用(未找到函数*),python,vb.net,dll,ctypes,Python,Vb.net,Dll,Ctypes,我努力在VB中创建dll,它将在python中可见 当我将dll导入python时,没有一个VB函数可见 我是这样做的: 有史以来最简单的VB类 我将其另存为dll(从Visual Studio 2010生成) 我通过将其导入其他VB项目来尝试它是否有效(工作正常): 我将其加载到python中并尝试使用它: 从ctypes导入* MojaDLL=cdll.LoadLibrary(“E:\\ClassLibrary1.dll”) MojaDLL.MyFunctions 回溯(最近一次呼叫最后一次

我努力在VB中创建dll,它将在python中可见

当我将dll导入python时,没有一个VB函数可见

我是这样做的:

  • 有史以来最简单的VB类
  • 我将其另存为dll(从Visual Studio 2010生成)

  • 我通过将其导入其他VB项目来尝试它是否有效(工作正常):

  • 我将其加载到python中并尝试使用它:
  • 从ctypes导入*
    MojaDLL=cdll.LoadLibrary(“E:\\ClassLibrary1.dll”)
    MojaDLL.MyFunctions
    回溯(最近一次呼叫最后一次):
    文件“”,第1行,在
    文件“C:\Python25\lib\ctypes\\uuuu init\uuuuu.py”,第361行,在\uuu getattr中__
    func=self.\uuuu getitem\uuuuu(名称)
    文件“C:\Python25\lib\ctypes\\uuuu init\uuuuu.py”,第366行,在\uuu getitem中__
    func=self.\u FuncPtr((名称或顺序,self))
    AttributeError:未找到函数“MyFunctions”
    
    我也尝试了MyDll.MyFunctions,而不是MyDll.MyFunctions:
    MyDll.MyFunctions(),MyDll.MyFunctions.AddMyValues(1,2),MyDll.MyFunctions.AddMyValues

    这里怎么了?我不明白


    还有一个类似的未解决的问题:

    在dll上使用
    /exports
    /linkermember
    选项来查看dll中实际导出的名称。

    您不能这样做。您正在生成的DLL是.NET程序集,或者,如果您公开COM接口,则它是COM组件


    Python的
    ctypes
    模块只支持。

    PS。当我将dll注册为COM时,它工作得很好。也许这些文章会有所帮助:and.aaaah:/所以有没有办法在Python中使用vb dll?来自COM的Aprat,它似乎没有那么健壮(注册名称、每个名称一个dll、硬更新等)@Intelligent Infrastructure Python可能有一个.NET绑定,但我实际上对此表示怀疑–COM似乎是唯一的方法。
    Public Class MyFunctions
            Public Function AddMyValues(ByVal Value1 As Double, ByVal Value2 As Double)
                Dim Result As Double
                Result = Value1 + Value2
                Return Result
            End Function
        End Class`
    
        Imports ClassLibrary1
    Module Module1
    
        Sub Main()
            Dim Nowa As New ClassLibrary1.MyFunctions
    
            Dim Result As String
            Result = Nowa.AddMyValues(123, 456.78).ToString
            Console.WriteLine(Result)
            Console.ReadLine()
        End Sub
    
    End Module
    
    from ctypes import *
    MojaDLL = cdll.LoadLibrary("E:\\ClassLibrary1.dll")
    MojaDLL.MyFunctions
    Traceback (most recent call last):
      File "<console>", line 1, in <module>
      File "C:\Python25\lib\ctypes\__init__.py", line 361, in __getattr__
        func = self.__getitem__(name)
      File "C:\Python25\lib\ctypes\__init__.py", line 366, in __getitem__
        func = self._FuncPtr((name_or_ordinal, self))
    AttributeError: function 'MyFunctions' not found