Next: , Previous: C++ Class Interface, Up: Top   [Index]


13 .Net Interface

This chapter describes the Microsoft.Net wrapper around MPIR.

If you are a .Net developer on MS Windows, using MPIR is possible via the basic managed-to-native interop tooling provided by .Net. While this would allow access to the full MPIR intreface, you would essentially be embedding C code inside whatever .Net language you are using. This would virtually require familiarity with C/C++, the interop artefacts in your code would be distractingly evident, and it would be hard to maintain a smooth code style around managed/native transitions.

MPIR offers an alternative that addresses these issues: MPIR.Net. MPIR.Net is a Microsoft Visual Studio solution that interoperates with MPIR and exposes a full managed interface built from scratch, for consumption in any .Net language. It internalizes all C-rooted idiosynchrasies and allows you to work with MPIR objects through managed classes that perform all necessary marshaling behind the scenes. It strives to provide maximum performance by implementing MPIR operations with direct calls to the native routines while not requiring you to sacrifice any of your code style. It eliminates any requirement of fluency in C, yet delivers the performance of native MPIR. In fact, it can consume any native MPIR build, including all supported processor-specific builds, and can thus take advantage of the entire wealth of assembly-optimized MPIR routines.

MPIR.Net is, however, limited to MS Windows and Visual Studio at this time. The managed interface is written in Microsoft C++/CLI, which ties you to that specific environment. If you use .Net on Linux and use a compiler other than Visual Studio, MPIR.Net will not work for you, but then again, you may already have better native interop facilities available to you than your Windows colleagues, making MPIR.Net rather moot.

MPIR.Net is bundled with MPIR as an optional feature. To build it, you still need to build the native MPIR library first. As you do, you can select the best processor architecture that matches your requirements. Then you build MPIR.Net, and it is linked statically to the native MPIR library, producing a managed assembly. Thus, to build MPIR.Net, you need to be familiar with the MPIR build process on Windows, and have a recent version of Visual Studio available (a community edition will suffice).


Next: , Previous: C++ Class Interface, Up: Top   [Index]