This project shows how to call C# (.NET) code from an Igor XOP

You'll need to use both the XOP Toolkit and a recent edition of Microsoft Visual Studio. You'll also have to write a very small amount of C++/CLI, Microsoft's C++ -like language that lets you mix managed .NET code with traditional C++.

The basic idea is to compile the XOP with the /clr compiler switch, and in places where the XOP functions are executed, put in C++/CLI calls to the external C# code.

To build and test:

  1. Make sure you've built the XOPSupport project in your XOP Toolkit folder
  2. Set an environment variable called XOPSupport to point to the XOPSupport directory and ensure that both Igor.lib and XOPSupport.lib are in that directory. The project files here use that variable to locate headers and libraries.
  3. Download and build this solution. It will put MyCSharpLib.dll and MyXOP.xop in XOP.NET\output
  4. In your Igor Extensions folder, make a shortcut to MyXOP.xop.
  5. Start Igor
  6. Enter  Print MyFunc(6,7) You should see '42.' That multiplication was done by the C# code.

The XOP includes a file called DllResolver.cpp to help the .NET runtime library loader find your custom .NET library. Without it, the standard Windows library search behavior doesn't work properly.

If you only have access to the 'Express' (free) versions of Visual Studio, the XOP.NET.sln 'solution' file won't work for you. Instead, open the 'project' files MyXOP.vcproj and MyCSharpLib.csproj individually. You may need to mess with some settings in the VC project so it can find the C# library dependency.

Some parts of the source code are copies, or modified versions, of the example code in the XOP Toolkit. The modifications, and the new code are provided under the open source BSD license.

Update Nov 2013 I'm doing Igor XOP development again. I've updated the source code and put it in GitHub repo

Project Details

Project Homepage: View Homepage
Project License: http://creativecommons.org/licenses/BSD/

Current Project Release

XOP.NET IGOR.6.30.x-1.1

Release File: igor-xop.net_.zip
Version: IGOR.6.30.x-1.1
Version Date: Tue, 11/26/2013 - 12:01 pm
Version Major: 1
Version Patch Level: 1
OS Compatibility: Windows
Release Notes: Updated to use XOP Toolkit version 6, with Igor 6.3. Built with Visual Studio 2012.

Source code is also available on GitHub
View All Releases




Igor Pro 9

Learn More

Igor XOP Toolkit

Learn More

Igor NIDAQ Tools MX

Learn More