Slides for my talk at MIX11: Fun with ASP.NET MVC 3, MEF and NuGet

Edit on GitHub

As promised, here are the slides and demo code for my talk "Fun with ASP.NET MVC 3, MEF and NuGet" I presented at MIX in Las Vegas.

Abstract: "So you have a team of developers… And a nice architecture to build on… How about making that architecture easy for everyone and getting developers up to speed quickly? Learn all about integrating the managed extensibility framework (MEF) and ASP.NET MVC with some NuGet sauce for creating loosely coupled, easy to use architectures that anyone can grasp."

The recorded session: (on Channel 9)

 

The slide deck:

The demo code: 2011-04-14 Fun with ASP.NET MVC 3 MEF.zip (6.76 mb)

Enjoy! And thanks for joining!

kick it on DotNetKicks.com

This is an imported post. It was imported from my old blog using an automated tool and may contain formatting errors and/or broken images.

Leave a Comment

avatar

6 responses

  1. Avatar for binjiezhao
    binjiezhao April 30th, 2011

    Hi Maarten

    Thanks for sharing the demo code. It&#39s all very exciting technologies.
    I have found a little glitch in the msbuild script(might not be a glitch at all depending where you put the source code):

    <Exec WorkingDirectory="$(PackagesPublishDir)"
    Command="$(NuGetExe) pack $(BuildDir)\temp\Package\package.nuspec" />

    Above line gives a msb error with exits code of 9009. After I added escaped quots around the command and params, it works:
    <Exec WorkingDirectory="$(PackagesPublishDir)"
    Command="&quot;$(NuGetExe)&quot; pack &quot;$(BuildDir)\temp\Package\package.nuspec&quot;" />

    But I still have to run the build script for a number of times to get rid of an "assembly or dependencies not found error" in all the build scripts of the components at line 40. Seems you have to run it twice to build each of them. I can&#39t figure out why.

  2. Avatar for binjiezhao
    binjiezhao April 30th, 2011

    Food for thought here Maarten. I know what you have demoed is probably what a lot of people are after. But what if there&#39s a SOA element? For example: you have a dependency of a wcf server in your controller, how would you go about using MEF to inject the dependency? I tried manually adding mef export attribute to the service client, it worked but not ideal. I changed the wcf service so that it lends iteslf to MEF. But the generated client proxy hasn&#39t got any MEF attributes at all. I don&#39t know how feasible is it to extend svcutil.exe to do that leg work. Is there any way to do this automatically?
    Thanks.

  3. Avatar for maartenbax
    maartenbax April 30th, 2011

    Thanks for noticing!

    I also have the problem having to build twice, I think it&#39s a hard disk issue as on my slower PC (with slow HD) it builds the first time. On my SSD, I have to build twice.

  4. Avatar for maartenbax
    maartenbax April 30th, 2011

    Have done that one as well. There&#39s some options for that.

    Option 1) Make your service proxy "partial&#39" and add an [Export] on the partial
    Option 2) Don&#39t use the service proxy generated, instead use the service client without a proxy. Only thing needed is a class inheriting this client on which you can place the export
    Option 3) Embed the proxy in another object and use that object
    Option 4) The cleanest IMHO: use the MefContrib convention-based model to export the proxy at runtime. E.g. add a MefContrib convention which exports all classes with the name of your service proxy.

    BTW, service configuration can be embedded in NuGet packages and applied to your web/app.config.

  5. Avatar for binjiezhao
    binjiezhao May 3rd, 2011

    Hi Maarten

    Thanks for the suggestions. Option 1 and 4 sounds interesting. I will give them a go. Also that&#39s a good tip about config transfer using NuGet.

  6. Avatar for khalid
    khalid August 2nd, 2011

    Thank you very much