Reputation: 1132
I'm experimenting with creating a plugin framework for ASP.NET MVC. I've managed to inject the controllers dynamically, but I've hit the wall when loading the view templates.
I've debugged MVC and located the problem to the following call:
BuildManager.GetObjectFactory("~/Views/HelloWorld/Index.cshtml")
The problem isn't that the path does not exist, but that it does not compile. The view is typed to use HelloWorldPlugin.Models.Message as a model, but it seems the BuildManager can't find the type. I had a look in Temporary ASP.NET Files and as expected, HelloWorldPlugin.dll does not exist there.
What stumps me is that before the application starts, I make a call to BuildManager.AddReferencedAssembly, passing the HelloWorldPlugin assembly as the parameter. This works fine for making MVC find the controller, but why isn't the BuildManager installing it to Temporary ASP.NET Files, and why can't it find it when compiling the view?
Upvotes: 0
Views: 916
Reputation: 59031
Your plugin assembly won't get copied to Temporary ASP.NET Files. Assemblies are loaded from the bin folder. BuildManager.AddReferencedAssembly is merely adding an assembly reference to the one that should be loaded in memory. It's equivalent to adding the assembly to the application-level Web.config file.
Can you share the exact error message you're getting. Did you check your bin folder to make sure that your plugin assembly is referenced properly?
Upvotes: 2