Loosely bound parts?

Sep 16, 2009 at 3:08 AM

Is there a way to provide loosely bound parts to the host application?  For instance, I might want to implement an export part that doesn't reference any host DLLs for the interfaces. 

This would be like a duck typing catalog, I suppose.  Are there any plans to do this?  Should I just consider writing a catalog like that myself? 

<input id="gwProxy" type="hidden" /><input id="jsProxy" onclick="jsCall();" type="hidden" />

Sep 16, 2009 at 8:42 AM

Hi Brian

Can you give a concrete example of what you are trying to do? Are you saying that you have a part called Foo that imports IBar, but you want Foo to reference a different IBar that the exporter Bar will reference?

Glenn

From: BrianGenisio [mailto:notifications@codeplex.com]
Sent: Tuesday, September 15, 2009 7:09 PM
To: Glenn Block
Subject: Loosely bound parts? [MEF:69056]

From: BrianGenisio

Is there a way to provide loosely bound parts to the host application? For instance, I might want to implement an export part that doesn't reference any host DLLs for the interfaces.

This would be like a duck typing catalog, I suppose. Are there any plans to do this? Should I just consider writing a catalog like that myself?

<input id="gwProxy" type="hidden" /><input id="jsProxy" onclick="jsCall();" type="hidden" />

Read the full discussion online.

To add a post to this discussion, reply to this email (MEF@discussions.codeplex.com)

To start a new discussion for this project, email MEF@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com

Sep 16, 2009 at 11:21 AM

Glenn,

You've got it.  I want to have my app import IFoo.  The exported part is defined by someone else -- a user -- like a plug-in.  IFoo is defined in my app, and I don't want my plug-in author to rely on linking against my app.  I'd rather tell the plug-in author that IFoo is defined like this: public interface IFoo {...}.  The author could just copy/paste that interface into their DLL, implement the interface, and not have to worry about which version of my DLL to link against.

One reason I might want to do this:  I am working on a Silverlight app and I want to let my users give me plug-ins.  Instead of providing a DLL from the Silverlight app, I would prefer to just say: "This is what the interface looks like.  Conform to it, and I will import you.

Essentially, I am talking about duck typing inside the catalog, I think.  The catalog would create dynamic bridges between the exported version of the interface and the imported version of the interface, just as long as it matches.

I am mostly just brainstorming right now... but a few years ago, I wrote a plug-in subsystem.  We continue to have difficulties with our plug-in authors linking against the wrong version of the DLL, and the reflection fails to match up the correct interfaces even if they didn't change.  They need to recompile their plug-in against the new DLLs and re-publish, which is a pain and they complain about it.  I keep meaning to find the time to fix that, but of course, it is not trivial.  There are ways of doing it... there are several implementations of dynamic proxies on the web... I have even implemented my own.  A DuckTyping catalog would be swell :)

 

Developer
Sep 20, 2009 at 7:06 AM

Currently there really isn't any duck-typing support in .Net (or Silverlight). However in .Net 4 there is a new feature commonly referred to as No-Pia which will get you some of the way you wish to go. Have a look at https://channel9.msdn.com/tags/No-PIA/ for more information around this.

Sep 20, 2009 at 10:01 PM

@weshaggard: Although I agree that there isn't any duck-typing support in native C#, I don't agree that there isn't duck typing in .Net.  The DLR gives support for it (ex IronRuby).  I have also created a duck typing utility that can be used in C# for exactly that reason.  It allows you to do this:

IDoSomething foo = classThatDoesntImplement.As()

It is called DynamicWrapper and it was pretty easy to write.  I was thinking of writing a catalog that uses my DynamicWrapper to do this.  Before I did such a thing, I thought I would see if MEF had any such support.

 

Sep 21, 2009 at 2:11 AM

Thanks Brian! We actually are looking into the possibility of baking in duck typing support via the DLR in a future release of MEF.  In the meanwhile if you have anything MEF specific, please consider adding it to MEF Contrib (mefcontrib.codeplex.com).


Regards

Glenn

From: BrianGenisio [mailto:notifications@codeplex.com]
Sent: Sunday, September 20, 2009 2:01 PM
To: Glenn Block
Subject: Re: Loosely bound parts? [MEF:69056]

From: BrianGenisio

@weshaggard: Although I agree that there isn't any duck-typing support in native C#, I don't agree that there isn't duck typing in .Net. The DLR gives support for it (ex IronRuby). I have also created a duck typing utility that can be used in C# for exactly that reason. It allows you to do this:

IDoSomething foo = classThatDoesntImplement.As()

It is called DynamicWrapper and it was pretty easy to write. I was thinking of writing a catalog that uses my DynamicWrapper to do this. Before I did such a thing, I thought I would see if MEF had any such support.

Read the full discussion online.

To add a post to this discussion, reply to this email (MEF@discussions.codeplex.com)

To start a new discussion for this project, email MEF@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com

Developer
Sep 21, 2009 at 7:36 PM

@BrianGenisio - You are correct using the DLR you can create some form of duck typing but at this time MEF does not have any support for it included. I think exploring the idea of creating a catalog that uses DynamicWrapper would be worth exploring and seems like an interesting experiment. Let us know what you come up with.