MEF, The DLR, IronRuby, and the Web

Uncategorized Add comments

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 cname
  5:   end
  6:
  7:   attrs["ExportTypeIdentity"]=contract_name(cname)
  8:
  9:   export_attr(cname, attrs) do
 10:     self
 11:   end
 12: end
 13:
 14: def self.create_export_def(cname, attrs, accessor)
 15:   metadata = System::Collections::Generic::Dictionary[System::String,System::Object].new
 16:   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”

  1. Nicholas Blumhardt Says:

    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

  2. Chris Says:

    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

  3. Chris Says:

    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.

  4. CAMERON Says:

    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”>.…

  5. TOMMY Says:


    Medicamentspot.com. Canadian Health&Care.Special Internet Prices.Best quality drugs.No prescription online pharmacy. No prescription pills. Buy pills online

    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….

  6. omaha Says:

    santa http://obathroomvcqq7.ANTIQUEFURNINISHING.INFO/tag/parade+santa+omaha/ : omaha…

    omaha…

Leave a Reply

You must be logged in to post a comment.