委托如何返回字符串生成器?

问题描述

第一次

delegate System.Text.StringBuilder get_content_func(uint i);

然后

get_content_func func = _content;
system.intPtr p = Marshal.GetFunctionPointerForDelegate(func);//error - stack over flow

并且'p'将被注册到c++,并且会在某个时间被回调以获取字符串内容。 C++部分

typedef char* (__stdcall* GetContenFunc)(unsigned int id);//char*
void register_get_page_content(GetContenFunc GetHandle) {
        g_GetHandle = GetHandle;//g_GetHanle is a global pointer
}

//func to call g_GetHandle

void get_page(guid id) {
        char* content;
        if (g_GetHandle != nullptr) {
            content = g_GetHandle(id);
        }
    }

目的是从方法 '_content ' 中获取字符串,该方法用于发送到 cpp 以执行其他操作。 'p' 将是一个回调函数,用于通过 stringbuilder 获取内容。 但是失败了,怎么解决

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)