After seeing Glenn Block talk about MEF in phoenix last week, I began to write a demo for work.
We have a pretty big pain point in our flagship product at work and I think that MEF would be a great way to alleviate that pain. Specifically, I would love to be able to just simply script that part of the application.
Enter Nicholas Blumhardt’s post about hosting IronRuby parts in MEF.
Nick has done quite a great job getting this to work. I had to update his code very little to use the latest version of MEF and the DLR.
Specifically, I had to add the “ExportTypeIdentity” metadata value to all ruby objects being exported.
1: def self.export(cname, attrs={})2:3: if cname.is_a?(Module)4: include cname5: end6:7: attrs["ExportTypeIdentity"]=contract_name(cname)8:9: export_attr(cname, attrs) do10: self11: end12: end13:14: def self.create_export_def(cname, attrs, accessor)15: metadata = System::Collections::Generic::Dictionary[System::String,System::Object].new16: attrs.each{|key, value| metadata.add key, value}17: RubyExportDefinition.new(contract_name(cname), metadata, accessor)18: end
This works freaking great in my little test console app. But, it will not work for some reason in a web context. And as luck would have it, our flagship product is a web application.
This is the error I can’t seem to get around.
1) The export ‘ClassLibrary1.IContract’ is not assignable to type ‘ClassLibrary1.IContract’.
Has anyone made this work?
Download a demo here


