I'm developing an asp.net mvc 4 site, using Simple Injector as a Ioc tool. It would be a pluggable architecture. Some controllers and views are in another assembly (another mvc4 application, Plugin.Web.dll). And from the main application, I know the path of Plugin.Web.dll, loading the plugin.
container.RegisterMvcControllers(Assembly.GetExecutingAssembly());
container.RegisterMvcAttributeFilterProvider();
container.Options.AllowOverridingRegistrations = true;
var appPath = AppDomain.CurrentDomain.BaseDirectory;
string[] files = Directory.GetFiles(appPath + "\\Plugins", "*",
SearchOption.AllDirectories);
foreach (var fileName in files)
{
Console.WriteLine(fileName);
var assembly = Assembly.LoadFrom(fileName);
container.RegisterMvcControllers(assembly);
var controllerTypes =
from type in assembly.GetExportedTypes()
where type.Name.EndsWith("Controller",
StringComparison.Ordinal)
where typeof(IController).IsAssignableFrom(type)
where !type.IsAbstract
select type;
// Instead of verify:
foreach (var type in controllerTypes)
{
container.GetInstance(type);
}
}
container.Options.AllowOverridingRegistrations = false;
container.Verify();
DependencyResolver.SetResolver(
new SimpleInjectorDependencyResolver(container));
It gives no errors.
But when I click this click, in view:
@Html.ActionLink("plugin page","PluginPage","Plugin")
It gives 'The resource cannot be found., http 404'
thanks in advance