Since the beginning of my experience writing in C#, I've also wanted to be able to re-use many of the great perl modules from within C# code. There are a ton of great algorithms already fully implemented on CPAN that could be put to good use in C#. Even just using simple modules like Getopt::Long and POD::Usage could make creating command line utilities so much easier.
So, after quite a bit of slogging through Google research, looking at the various available possibilities, and reading these posts, I went ahead and designed an implementation for using arbitrary perl expressions within C#.
I wrote a simple utility called NEW-GUID to serve as a fully implemented example of embedding perl in C#. It uses the PerlScript technique noted by
bmcnett in his prior
reply. It does double duty, also serving as an example using a replacement Win32 command line parser that I've written, Win32::CommandLine.
So, I've included it in that module on CPAN (see
Win32::CommandLine).
Download it and look in the "extras" directory. The 'NEW-GUID.zip' file contains the C# source, a compiled executable, and a build script that should work on any Windows PC with Framework 2.0+ installed (that is any Vista+ OS or XP with dotnetfx v2.0+ installed).
Right now, because of the PerlScript requirement, it requires an ActiveState perl installation, but it should be possible to refactor it into a form using just the perlXX.dll and a C# wrapper. (It might even be portable to Mono in that situation.)
Full details on requirements and how to build the source are included in the README. All requirements are freely available and detailed instructions on how to obtain and install them are included in the README as well.
Using the technique displayed in the code, you can run any arbitrary perl code, returning an arbitrary LIST of results (which can contain SCALARS and refs to SCALARS, ARRAYS,
and/or HASHES to any arbitrary depth). The code to transfer any arbitrary structures across the COM/Active Script boundary is included and is fully implemented.
Hope this helps.