- Embedding Python Scripts in .NET Applications
- Identifying Source Code and Project
- Embedding the Script
- Conclusion
Identifying Source Code and Project
The first thing to do is identify where the script should go in the application's source code. In this example/scenario, it will be in a new dialog that is added to the project that contains the toolset. This new dialog will be triggered by an existing process that handles the toolbar clicks.
After the project containing the source code has been identified, the IronPython libraries need to be referenced by the project.
If you use Visual Studio as the source code editor, the easiest way is to use the Nuget Package Manager to add the IronPython libraries to the project. You can do this by simply searching for "IronPython", and the runtime will appear for selection within the package manager.
You can also download the IronPython runtime from Codeplex at https://ironpython.codeplex.com/. After downloading, simply add a reference to the IronPython lib folder located at C:\Program Files (x86)\IronPython <version>/Lib. You will also need to add a reference to the Microsoft.Scripting.Core.dll to your project.