0
내 목표는 파이썬 스크립트 ctypes 라이브러리에서 C# DLL 파일 기능에 액세스하는 것입니다. 내 C# 코드는 다음과 같습니다파이썬 코드에서 C# DLL 기능 액세스
import ctypes
a=ctypes.cdll.LoadLibrary('File Location')
a.MyFunctionName("a")
하지만 오류 AttributeError 무엇입니까 :
는using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using RGiesecke.DllExport;
using System.Runtime.InteropServices;
namespace ConsoleApp1
{
[ComVisible(true)]
public class Program
{
[DllExport("MyFunctionName", CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.LPWStr)]
public static string MyFunctionName([MarshalAs(UnmanagedType.LPWStr)] string iString)
{
return "hello world i'm " + iString;
}
[DllExport("Add",CallingConvention = CallingConvention.Cdecl)]
public static int Add(int a, int b)
{
return a + b;
}
[DllExport(CallingConvention = CallingConvention.Cdecl)]
static public int Subtract(int a, int b)
{
return a - b;
}
[DllExport(CallingConvention = CallingConvention.Cdecl)]
static public int Multiply(int a, int b)
{
return a * b;
}
[DllExport(CallingConvention = CallingConvention.Cdecl)]
static public int Divide(int a, int b)
{
return a/b;
}
static void Main(string[] args)
{
//Console.Write(Add(2,3));
}
}
}
및 파이썬 코드는
어떻게 할 수
를 찾을 수없는 기능을 'MyFunctionName' DLL 파일에 포함 된 함수에 액세스 할 수 없으므로 오류를 해결 하시겠습니까?
솔루션 플랫폼을 x64로 앞에서 설정했지만 여전히 오류가 발생합니다. –