Python中的C#DLL返回类型
我有一个简单的问题,我创建了一个基本的C#CLL库,我正在从Python2.7调用它。我在C#中使用以下命令使我的函数可以从外部调用:Python中的C#DLL返回类型,c#,python,dll,return-type,dllexport,C#,Python,Dll,Return Type,Dllexport,我有一个简单的问题,我创建了一个基本的C#CLL库,我正在从Python2.7调用它。我在C#中使用以下命令使我的函数可以从外部调用: using System.Runtime.InteropServices; using RGiesecke.DllExport; [DllExport("StartFrequency", CallingConvention = CallingConvention.Cdecl)] public static double StartFrequency(double
using System.Runtime.InteropServices;
using RGiesecke.DllExport;
[DllExport("StartFrequency", CallingConvention = CallingConvention.Cdecl)]
public static double StartFrequency(double start)
{
if (start != 0)// this is a set request
{
Console.WriteLine(start.ToString() + " Set Request");
try
{
//driver.DriverOperation.QueryInstrumentStatus = false;
driver.System.ClearErrors();
driver.Frequency.Start = (double)start;
driver.DriverOperation.QueryInstrumentStatus = true;
return 1;
}
catch
{
Console.WriteLine("Cannot Write Start Value");
return 0;
}
}
else// this is a get request
{
Console.WriteLine("Get Request");
try
{
driver.System.ClearErrors();
return driver.Frequency.Start;
}
catch
{
Console.WriteLine("Cannot Read Start Value");
return 0;
}
}
}
问题是,即使我尝试返回一个不同的变量类型,如string、float或bool,在Python中它仍然认为返回类型始终是Int。
以下是我的python代码:
driver = ctypes.cdll.LoadLibrary(DLL)
a = driver.StopFrequency(c_double(600000000))
我也试过这样的方法:
driver = ctypes.cdll.LoadLibrary(DLL)
a = c_double(0.0)
a = driver.StopFrequency(c_double(600000000))
无论我的C#函数的返回类型是什么,Python总是假定Int
关于如何解决这个问题有什么建议吗?有人能帮忙吗?有人能帮忙吗?