Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/337.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
导入c+时c#中的堆栈溢出异常+;动态链接库_C#_Dllimport_Stack Overflow - Fatal编程技术网

导入c+时c#中的堆栈溢出异常+;动态链接库

导入c+时c#中的堆栈溢出异常+;动态链接库,c#,dllimport,stack-overflow,C#,Dllimport,Stack Overflow,我有一个C#类库项目,其中有以下方法: public string GetPackagestring(string devID, string ConfigName) { //my code here string ProgramName="VOT"; //here I call a c++ Dll function packagestring = getparameters(devID, ConfigName, ProgramName); //other

我有一个C#类库项目,其中有以下方法:

public string GetPackagestring(string devID, string ConfigName)
{
    //my code here
    string ProgramName="VOT";
    //here I call a c++ Dll function
    packagestring = getparameters(devID, ConfigName, ProgramName);
    //other part of code 
}
调用外部dll函数时,在packagestring行中出现Stackoverflow异常

在我的项目中,我正在导入DLL,如下所示

public partial class Form1 : Form
{
    //Import DLL
    [DllImport(@"\DLL\testconfigdump.dll", CharSet = CharSet.Ansi, EntryPoint = "getparameters", CallingConvention = CallingConvention.Cdecl)]
    [return: MarshalAs(UnmanagedType.BStr)]
    public static extern string getparameters(string pumpid, string configname, string progname);
    ...
}
有人能帮我解释为什么我会遇到stackoverflow问题吗?

消息说当前线程处于stackoverflow状态。

您需要提供用于编译dll的代码,否则很难说发生了什么。GetPackageString是否在循环中调用?您必须在C中使用
StringBuilder
,而不是
string
。在C中提供
getparameters
的代码也很有帮助。