在Linux上使用CoreCLR从C调用C#方法
发布时间:2020-12-13 22:57:08 所属栏目:Linux 来源:网络整理
导读:我发现 that code允许在Linux上的托管CLR上执行C#程序集.但我想只调用C#dll中的一些方法.我已经尝试过 this和 this,但我不知道如何在Linux上正确包含或重新定义: ICLRMetaHost,ICLRRuntimeInfo,ICLRRuntimeHost,CLSID_CLRMetaHost,IID_ICLRMetaHost,IID_ICL
我发现
that code允许在Linux上的托管CLR上执行C#程序集.但我想只调用C#dll中的一些方法.我已经尝试过
this和
this,但我不知道如何在Linux上正确包含或重新定义:
ICLRMetaHost,ICLRRuntimeInfo,ICLRRuntimeHost,CLSID_CLRMetaHost,IID_ICLRMetaHost,IID_ICLRRuntimeInfo,CLSID_CLRRuntimeHost,IID_ICLRRuntimeHost 您是否有任何想法或链接到某些代码,这些代码在Linux上使用CoreCLR从C调用C#? 我只对Linux上的CoreCLR感兴趣(不是Mono!). 解决方法
好的,我发现为了获得C#函数的委托,你必须使用coreCLR提供的这三个函数:
// this one first,to initialize coreCLR int (coreclrInitializeFunction)( const char* exePath,const char* appDomainFriendlyName,int propertyCount,const char** propertyKeys,const char** propertyValues,void** hostHandle,unsigned int* domainId); // this one to get delegate to your C# function int (coreclrCreateDelegateFunction)( void* hostHandle,unsigned int domainId,const char* entryPointAssemblyName,const char* entryPointTypeName,const char* entryPointMethodName,void** delegate); // this one on the end,to close coreCLR int (coreclrShutdownFunction)( void* hostHandle,unsigned int domainId); 这是我调用C#函数的示例代码,它调用C对象上的C方法:https://github.com/Marqin/simpleCoreCLRHost (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |