by Mwwhited
31. October 2009 14:20
I prefer to write mostly in .Net and C# these days. But sometimes you need to work with external systems. On particular system I have been working with supports COM interop but the deployment model leaves much to be desired. In my typical net surfing I found a IL hack to export method calls from .Net assemblies and expose them as Unmanaged references. The handy part about this it you can use the exports anywhere you may call unmanaged interfaces.
The need for me was with WinBatch. Winbatch has support for COM but I really don't want to be required to register all of my .Net assemblies as COM objects. By using ILDASM, ILASM, and SN I have written a simple post-compiler. By using the UnmanagedExports.Common.DllExportAttribute to tag you public static methods the tool will recompile the assembly and expose the unmanaged exports. Right now this is a quick demo app with no support but I have provided it free to use for those willing to have fun. The best part about it is being able to expose .Net assemblies to external systems without writing a single line of C/C++ code.
Another feature that I have baked in is the ability to resign assemblies during the post-processing.
UnmanagedExports.zip
-Enjoy