Search code examples
asp.net-mvcviewstrong-typing

ASP.NET MVC - How to create a strongly-typed view from classes in referenced class-library?


i'm trying to create a strongly-typed view using Visual Studio 2008. I can right-click a controller action and choose: Add view... In the next dialog window there is an option 'Create a strongly-typed view'. If I check this option I can select a list of classes that are in my current project.

However I cannot select the class I need which is in a class-library that I referenced.

  • The classlibrary is a strongly-typed assembly which is loaded in the GAC.
  • Obviously the library is referenced in the project.
  • I've added a <add namespace="namespace" /> in web.config
  • I've rebuilt multiple times, and restarted VS
  • Classlibrary doesn't have any problems...

Any suggestions?


Solution

  • Just create you view with any of the model classes then manually edit ASPX and replace the model class with the one you want. Probably the dialog window is just not intelligent enough.

    But in my personal opinion, using "outside" classes as your models is very wrong.

    All models, views and controllers should be here, directly in your project. They then can use internally whatever they need wherever it is.