在Linux上使用CoreCLR从C调用C#方法

在Linux上使用CoreCLR从C调用C#方法,第1张

概述我发现 that code允许在Linux上的托管CLR上执行C#程序集.但我想只调用C#dll中的一些方法.我已经尝试过 this和 this,但我不知道如何在Linux上正确包含或重新定义: ICLRMetaHost, ICLRRuntimeInfo, ICLRRuntimeHost, CLSID_CLRMetaHost,IID_ICLRMetaHost, IID_ICLRRuntimeIn 我发现 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 coreCLRint (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# functionint (coreclrCreateDelegateFunction)(              voID* hostHandle,unsigned int domainID,const char* entryPointAssemblyname,const char* entryPointTypename,const char* entryPointMethodname,voID** delegate);// this one on the end,to close coreCLRint (coreclrshutdownFunction)(            voID* hostHandle,unsigned int domainID);

这是我调用C#函数的示例代码,它调用C对象上的C方法:https://github.com/Marqin/simpleCoreCLRHost

总结

以上是内存溢出为你收集整理的在Linux上使用CoreCLR从C调用C#方法全部内容,希望文章能够帮你解决在Linux上使用CoreCLR从C调用C#方法所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/yw/1018132.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-23
下一篇 2022-05-23

发表评论

登录后才能评论

评论列表(0条)

保存