views:

646

answers:

4

Hi,

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?

+3  A: 

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.

User
I agree that I shouldn't use outside classes. However this -should- work. It is a read-only classlibrary which has collections and entities built-in. I like your suggestion of manually replacing, but this doesn't work, I get a compilation error probably because the inheritance is messed up: 'Title' is not a member of 'ASP.views_home_list_aspx'
Ropstah
The error I received is not related to my question. Your suggestion works. Thanks!
Ropstah
A: 

I'm not sure if my own classes show up in the list or not - I usually just type them (starting from the root namespace). What happens if you try to type in for example MyRootNamespace.MyClassLibrary.MyNamespace.AnotherNamespace.TheClass in the textbox and click OK?

Tomas Lycken
I can manually type the classname including namespaces, however the view content dropdown is then disabled...
Ropstah
A: 

I can manually type the classname including namespaces, however the view content dropdown is then disabled... – ropstah May 12 at 13:31

I'm having the same problem with my custom-created Data Classes. They show up in the "View Data Class" drop down but the "View Content" drop down is disabled. I'm guessing that my classes need to implement some interface. I'm just not sure which one.

shay
You might want to check this: http://msdn.microsoft.com/en-us/library/aa697427(VS.80).aspx . A very good ORM tool is Entityspaces, www.entityspaces.com
Ropstah
+1  A: 

This is surely to late for answering this question,but for future readers:

i noticed that very often i have to build->clean solution and then to build->rebuild solution and the classes magically appear (as they should)

Savvas Sopiadis