that approach in "possible duplicate" is different to the one in the book. The book's approach is to extend a managed .dll after compilation through a decompile, recompile process. The approach that you think is an exact duplicate is actually a pre compilation technique. I prefer method in the book because it is more AOP in style. Thanks for the link though. I will also explore this avenue
In Expert .NET 2.0 IL Assembler, in Ch 18 pp. 387 Serge Lidin talks about Creative Round-Tripping. He says, "ILAsm allows you to export the managed methods as unmanaged entry points".
I haven't heard this talked about anywhere else. Is this something that you can do in PostSharp? Are there any downloadable code / script examples of using this technique available?
To clarify, I don't want to use COM or Managed C++. So what's the best way to implement a call to a C# method from C/C++ through thunking?
ildasm, change corflags, add v-table info and export function, ilasm and you're done.
Here's a code project article: http://www.codeproject.com/Articles/37675/Simple-Method-of-DLL-Export-without-C-CLI
Which is based on:
Dead link:
http://www.csharphelp.com/2007/03/exporting-managed-code-as-unmanaged/
Wayback Machine for dead link: https://web.archive.org/web/20140213030149/http://www.csharphelp.com/2007/03/exporting-managed-code-as-unmanaged/
Which is based on: http://www.amazon.com/Inside-Microsoft-NET-IL-Assembler/dp/0735615470 (the first edition of the book you refer to)