Simple InjectorをIocツールとして使用して、asp.netmvc4サイトを開発しています。それはプラグ可能なアーキテクチャになります。一部のコントローラーとビューは別のアセンブリ(別のmvc4アプリケーション、Plugin.Web.dll)にあります。そして、メインアプリケーションから、プラグインをロードするPlugin.Web.dllのパスを知っています。
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));
エラーは発生しません。
しかし、このクリックをクリックすると、次のように表示されます。
@Html.ActionLink("plugin page","PluginPage","Plugin")
'リソースが見つかりません。、http404'
前もって感謝します