How do I create a .NET assembly in IronPython and call it from C#?

前端 未结 1 805
灰色年华
灰色年华 2020-12-30 03:59

I want to create an assembly using IronPython can call it from C#. Here are two things I am not asking.

  1. I\'m not asking how to call C# from IronPyt

相关标签:
1条回答
  • 2020-12-30 04:42

    This isn't really possible if your goal is to create an assembly which contains types that look like the types created by C#. The main problem here is that Python types work considerably differently than CLR types. For one thing, they can be mutated at runtime while CLR types are totally static. So the only way to achieve this today is to use the hosting interfaces to create a small C# stub which delegates the work to Python code.

    IronPython does have the ability to compile to an assembly -- which is what that blog post refers to -- but we did this primarily so that you could deploy an IronPython application to your customers without having to give them the source code.

    Feel free to follow up with a more specific scenario by adding a comment to this answer, and I'll be happy to provide advice on how to implement.

    0 讨论(0)
提交回复
热议问题