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
6 Responses to “MEF, The DLR, IronRuby, and the Web”
Leave a Reply
You must be logged in to post a comment.



June 3rd, 2009 at 3:53 pm
Hi Chris! I’m glad you found the MEF/Ruby post interesting and didn’t have too much trouble updating it.
I never tested the original code in a web scenario, so I can’t confirm that the issue was present, but I suspect it was. It looks to be related to the way that the script runtime is resolving assemblies.
You might find some help with this in the IronRuby community – unfortunately it isn’t something I know a lot about….
Best of luck, I hope it works out!
Nick
June 3rd, 2009 at 7:41 pm
Thanks for your reply, Nick.
After posting this, I had the realization that assembly resolution may be the issue I’m experiencing. Unfortunately, I haven’t had time to play with it again. I’m hoping to jump back on it tomorrow.
If I solve this problem, I’ll keep you in the loop.
-=Chris
June 11th, 2009 at 7:29 am
Well, I decided to move to IronPython for this. And after getting MEF export working, I decided that MEF was also overkill for what I need. It’s much easier to just scan a directory and compile the files myself.
June 24th, 2010 at 5:54 am
Medicamentspot.com International Legal RX Medications. Special Internet Prices (up to 40% off average US price). NO PRIOR PRESCRIPTION REQUIRED!…
Combivir@buy.online” rel=”nofollow”>.…
July 21st, 2010 at 11:47 am
Buy:Acomplia.Advair.Lipothin.Benicar.Aricept.Cozaar.Zetia.Seroquel.Lipitor.Female Pink Viagra.Nymphomax.Lasix.SleepWell.Buspar.Prozac.Female Cialis.Ventolin.Amoxicillin.Wellbutrin SR.Zocor….
August 29th, 2010 at 7:29 pm
santa http://obathroomvcqq7.ANTIQUEFURNINISHING.INFO/tag/parade+santa+omaha/ : omaha…
omaha…