views:

55

answers:

2

Is it possible to import a namespace from an assembly that is not in the bin folder?

I'm using ASP.NET MVC 2 with MEF to pull controllers out of the assembly.I was able to get everything working, however, strongly typed views can't recognize the assemblies' objects unless the assembly is in the bin folder.

+1  A: 

Strongly typed view means knowing the object type at compile time. In order to know the object at compile time the assembly containing the class needs to be referenced. Referencing assemblies in an ASP.NET application is done by putting them in the bin folder.

If you use reflection to load assemblies from some other non-standard location, types will be known only at runtime and you cannot use them as models for strongly typed views.

Darin Dimitrov
Compile time, I.E. after deploying the application. But why is it possible to change the views completely and have them run without recompiling? Or am I missing something here. Also, why doesn't using the <codebase> and <dependentAssembly> in the web.config work with this? http://msdn.microsoft.com/en-us/library/efs781xb.aspx
Baddie
`But why is it possible to change the views completely and have them run without recompiling` - it is not. Views are compiled by the ASP.NET runtime into assemblies when you hit the page for the first time.
Darin Dimitrov
If I was to use reflection, where would I load the assemblies so that I can use them as models for strongly typed views.
Baddie
A: 

If you want to load assemblies from somewhere else than the bin folder at runtime, you may do so by calling the appropriate method through the AppDomain.

Will Marcouiller
Where do I call this in an asp.net mvc application?
Baddie