开发者

how to register all classes in assembly with Castle Windsor in MVC 3

开发者 https://www.devze.com 2023-03-05 17:57 出处:网络
I\'m starting with ASP.NET MVC 3 and modules. Like the Orchard CMS modules, I want to have modules as assemblies with Razor pages (inside/outside the DLL). I followed Mika Kolari\'s tutorial, but I

I'm starting with ASP.NET MVC 3 and modules.

Like the Orchard CMS modules, I want to have modules as assemblies with Razor pages (inside/outside the DLL). I followed Mika Kolari's tutorial, but I don't know how to include all the classes from the assembly namespace in the core project with Castle Windsor.

I'm able to load Controller from the assembly, but not Model for the view. I get missing namespace error.

In Applic开发者_StackOverflow社区ation_start() I have:

var assembly = Assembly.LoadFrom(dll.FullName);
//different from Mika's
container.Register(AllTypes.FromAssembly(assembly)
                           .Where(t => t.Name.EndsWith("Model")));

and Settings.cshtml file invoking the error:

@{
Layout = ";~/Views/Shared/_Layout.cshtml";
var viewModel = Model as Crash.PageRating.SettingsViewModel; //error missing namespace Crash.PageRating
}

Mika says that @model does not work for him either.

Here is my solution

Thanks for help!

0

精彩评论

暂无评论...
验证码 换一张
取 消