views:

161

answers:

2

I am writing a compiler in F# and I want to be able to access the unmanaged metadata COM interfaces in the .net runtime. Before anybody mentions it, Reflection.Emit is not suitable for my purposes, nor do I want to use any other method than the metadata COM interfaces.

I've imported mscoree.tlb but it doesn't seem to include the interfaces I need.

The interfaces I'm interested in include IMetaDataEmit. Any sample code relating to this would be very useful, though I've not been able to find any so far.

C# samples would be fine as I can easily convert them to F#.

Thanks in advance to anybody who can help me with this rather cryptic query!

Update: I have now got this sorted by writing explicit COM references using the interface GUIDs!

+1  A: 

One option here would be to create your own project and compile these interfaces (using their definitions from cor.h) into a type library, which you could then tlbimp into a managed assembly. I realize it would be pretty tedious to convert the C header code into IDL, but that could possibly be automated (or partially automated) by some text-processing scripts.

Charlie
Thank you very much for your reply :-) However I have managed to sort this now using manual COM interfaces based on the GUIDs referenced in cor.h which turned out to be the best approach I think anyway!
kronoz
+1  A: 

I hope you found the mdbg sample which includes source code for wrapping exactly the interfaces you need.

Steve Steiner
Oh my good God I'm excited! Let's see if you're right...
kronoz