Mef2 Preview4: Add assemblies to MvcApplicationCatalog

Nov 1, 2011 at 2:45 PM

Hi, I'm doing some prototyping with the new v2Preview4 bits, and I have a question about adding assemblies to the MvcApplicationCatalog.

I see in the source that CompositionProvider.PostStartDefaultInitialize contains the code that creates the MvcApplicationCatalog, unioning its _partAssemblies assembly collection with the global application assembly (or its guess at the global assembly). There are also public static methods for adding parts assemblies to the _partAssemblies collection. 

That seems fine, but the problem is that by the time my code executes, the MvcApplicationCatalog is already created. The start process goes like this:

1) AssemblyInfo.cs contains the PreApplicationStartMethod attribute, pointing to the RequestCompositionScopeModule.Register method

2) RequestCompositionScopeModule.Register uses DynamicModuleUtility to register itself as an http module

3) RequestCompositionScopeModule.Init (IHttpModule.Init) calls CompositionProvider.PostStartDefaultInitialize

4) CompositionProvider.PostStartDefaultInitialize creates the MvcApplicationCatalog, and then registers all of the MVC3 IoC extension points, etc.

This all happens before Application_Start in my app, so how can we register additional assemblies before PostStartDefaultInitialize is called?

Thanks.

Nov 1, 2011 at 5:10 PM

I believe this can be disregarded, the reason I was not seeing my extra assemblies added to the catalog was because I wasn't properly copying them to the web app's bin directory. It seems to work OK now.

Nov 1, 2011 at 5:33 PM

Phew – you had us sweating for a second there! :)

Thanks very much for the follow-up, I’m looking forward to more of your feedback on the new preview.

Nick

From: pwideman [email removed]
Sent: Tuesday, November 01, 2011 10:10 AM
To: Nicholas Blumhardt
Subject: Re: Mef2 Preview4: Add assemblies to MvcApplicationCatalog [MEF:277892]

From: pwideman

I believe this can be disregarded, the reason I was not seeing my extra assemblies added to the catalog was because I wasn't properly copying them to the web app's bin directory. It seems to work OK now.