Logo

Maarten Balliauw {blog}

ASP.NET, ASP.NET MVC, Windows Azure, PHP, ...

About the author

Maarten Balliauw is currently employed as .NET Technical Consultant at RealDolmen. His interests are mainly web applications developed in ASP.NET (C#) or PHP and the Windows Azure cloud platform.
More about me More about me
Send mail E-mail me


ASP.NET MVC Quickly Pro NuGet Subscribe to my RSS feed Follow me on Twitter! View Maarten Balliauw's profile on LinkedIn
Maarten Balliauw - MVP - Most Valuable Professional
Maarten Balliauw - ASPInsider

Search

Latest Twitter

    Follow me on Twitter...

    Archive

    Disclaimer

    The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

    © Copyright Maarten Balliauw 2012


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

    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


    Comments (6) -

    binjiezhao United Kingdom |

    Friday, April 29, 2011 11:39 PM

    binjiezhao

    Hi Maarten

    Thanks for sharing the demo code. It's 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't figure out why.

    maartenbax Belgium |

    Saturday, April 30, 2011 12:46 PM

    maartenbax

    Thanks for noticing!

    I also have the problem having to build twice, I think it's 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.

    binjiezhao United Kingdom |

    Friday, April 29, 2011 11:47 PM

    binjiezhao

    Food for thought here Maarten. I know what you have demoed is probably what a lot of people are after. But what if there's 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't got any MEF attributes at all. I don't know how feasible is it to extend svcutil.exe to do that leg work. Is there any way to do this automatically?
    Thanks.

    maartenbax Belgium |

    Saturday, April 30, 2011 12:51 PM

    maartenbax

    Have done that one as well. There's some options for that.

    Option 1) Make your service proxy "partial'" and add an [Export] on the partial
    Option 2) Don't 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.

    binjiezhao United Kingdom |

    Tuesday, May 03, 2011 10:47 AM

    binjiezhao

    Hi Maarten

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

    khalid United States |

    Tuesday, August 02, 2011 5:08 PM

    khalid

    Thank you very much

    Pingbacks and trackbacks (1)+

    Comments are closed