[問題] Call C# DLL

看板Python作者 (reindeer)時間12年前 (2013/11/13 17:42), 編輯推噓2(202)
留言4則, 3人參與, 最新討論串1/1
請教一下 我現在有個想法是這樣的 在 .NET 用 C# 寫個 Class library 然後在 Python 利用 ctype 去 call 這個 DLL 檔 C# 程式內容 using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace PlusMinus { public class CheckPlusMinus { public CheckPlusMinus() { } public String Check(int inputInteger) { if (inputInteger > 0) { return "Plus"; } else if (inputInteger == 0) { return "0"; } else { return "Minus"; } } } } Python 程式內容 import ctypes dll = ctypes.CDLL("C:/Python 2.5/DLLs/PlusMinus.dll") dll.Check(333) 執行的回應是 Traceback (most recent call last): File "C:\Python 2.5\Lib\ctypes\__init__.py", line 353, in __getattr__ func = self.__getitem__(name) File "C:\Python 2.5\Lib\ctypes\__init__.py", line 358, in __getitem__ func = self._FuncPtr((name_or_ordinal, self)) AttributeError: function 'Check' not found 我確定 Python 有讀到 DLL 檔 可是不知道怎麼執行 function ... 謝謝 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 219.69.42.170

11/15 22:03, , 1F
你要不要先用windows的tool打開那個dll檔,看看是不是真
11/15 22:03, 1F

11/15 22:03, , 2F
的有Check這個function
11/15 22:03, 2F

11/16 11:37, , 3F
看成 Call of Duty ...
11/16 11:37, 3F

07/31 17:30, , 4F
請參考 IronPython http://goo.gl/3cIUex
07/31 17:30, 4F
文章代碼(AID): #1IWqc0GT (Python)
文章代碼(AID): #1IWqc0GT (Python)