No functions in C# DLL with RGiesecke.DllExport

前端 未结 3 1461
既然无缘
既然无缘 2021-01-04 23:05

I am trying to make a DLL in C# for use in a couple other languages. I found RGiesecke\'s DllExport but it doesn\'t seem to work. It builds just fine and makes a dll, but

相关标签:
3条回答
  • 2021-01-04 23:21

    This is a good question and worked for me. Just took a bit more time than it should due to the Python side where I made a mistake. Here is the working code in Python3 import sys import clr sys.path.insert(0,'C:\\your_path\\Py2NetComm\\bin\\Debug') clr.AddReference("Py2NetComm") import ToolServiceDLL as p2n ret = p2n.Class1.addUp(2,3) print("addUp:", ret)

    0 讨论(0)
  • 2021-01-04 23:33

    I had a similar problem, but had already set the platform target to x64 and had the following error:

    The name 'CallingConvention' does not exist in the current context

    I found adding the using directive System.Runtime.InteropServices resolve the problem.

    0 讨论(0)
  • 2021-01-04 23:34

    I found the problem. It has it in the RGiesecke Documentation, but I missed it. In the project settings->Build->Platform target: you can not have it set to "Any CPU". You must have it set to x64 or x86 depending on if you want to use it in a a 64 or 32 bit application.

    0 讨论(0)
提交回复
热议问题