我正在使用G-WAN 4.11.20
INIT.C
#pragma link "mono-2.0"
#pragma include "/home/igor/Projects/gwan_linux64-bit/mono-3.0.2"
#include "gwan.h" // G-WAN API
#include <mono/metadata/metadata.h>
#include <mono/metadata/loader.h>
#include <mono/metadata/object.h>
static MonoString* Sample ()
{
return mono_string_new (mono_domain_get (), "Hello!");
}
int main(int argc, char *argv[])
{
mono_add_internal_call("Gwan::Sample", Sample);
return 0;
}
gwan_api.cs
public class Gwan
{
[MethodImplAttribute(MethodImplOptions.InternalCall)]
extern public static string Sample();
}
gwan从断言开始:
ghashtable.c:236:断言&#39;哈希!= NULL&#39;失败
比调用脚本后,我遇到了同样的问题。
Unhandled Exception: System.MissingMethodException: Cannot find the requested method.
at (wrapper managed-to-native) Gwan:Sample ()
at hello2.Main (System.String[] args) [0x00000] in <filename unknown>:0
[ERROR] FATAL UNHANDLED EXCEPTION: System.MissingMethodException: Cannot find the requested method.
at (wrapper managed-to-native) Gwan:Sample ()
at hello2.Main (System.String[] args) [0x00000] in <filename unknown>:0
我的感觉是,我没有配置单声道权利,任何建议?
答案 0 :(得分:1)
与main.c
(维护脚本)不同,init.c
脚本必须终止,以便G-WAN服务器开始收听。
由于init.c
代码在执行后被释放,这使得它不适合存储应由G-WAN servlet调用的持久代码,以便为客户端请求构建动态内容。
您可能更有机会使用main.c
或G-WAN连接处理程序。
答案 1 :(得分:-1)
您必须为要从C#脚本支持的任何新G-WAN API(或外部函数)实现C#包装。