I'm trying to get the MVC project to compile and run but there seems to be various problems in both the release version and the version from the SVN trunk.
Currently with the version from Trunk it is missing references to the MVC dlls, as well as N" and N2.Extensions. I have taken the MVC dlls from the lib folder, and the other two directly from their respective projects, which has enabled me to successfully
compile the MVC test project. Unfortunately at runtime I get the following error from Windsor:
"Required configuration property startPageID not found"
I think that perhaps I'm not installing everything properly - the Prepare_Dependencies-vs2008.bat fails for me.
Any advice on how to get a working MVC project up and running would be most appreciated - I would much ratehr use MVC than web forms!
Thanks very much
Hello, some quick and dirty hacks to make Mvc sample running (at the very least ;-):
1. Drop any N2.mdf into ~/App_Data/. (In a recent release you can grab one from
Deploy\Source\examples\MediumTrust\wwwroot\App_Data after you've finished with
Deploy_Everything-vs2008.bat. Btw, the order you should run batches is this: 1)
Build_Everything-vs2008.bat 2) Deploy_Everything-vs2008.bat -- don't worry about eventual errors being reported -- they're most probably related to unit testing stuff)
2. web.config is somewhat out of sync with a recent N2 engine, so you should update it manually:
2.1 Remove all references to <castle/> (E.g.: from <configuration><configSections/></configuration> and elsewhere..)
2.2 Add a new-style declarations as in the following lines:
2.3 Add the following N2 config section somewhere inside <configuration/> section:
2.4 Mvc sample seems to use ASP.Net Mvc Preview 2. To make it work you need both dedicated http module, as well as a special http handler for routing. For some reason the latter is missing from web.config. Here's how it should be declared inside <httpHandlers/>
<!-- If you install a database from scrach you'll need to insert some required pages. This can be done by the web based installer located at http://yoursite/install/edit -->
<!-- These are only needed for medium trust
<!-- Other flavours: SqlServer2005, SqlServer2000, MySql, SqLite, SqlCe, Firebird -->
<installer checkInstallationStatus="false" />
<globalization enabled="true" />
(I expect question where to get System.Web.Routing.dll, but hope you'll find one ;-)
type="System.Web.Routing.UrlRoutingHandler, System.Web.Routing, Version=126.96.36.199, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
From now on chances are high the application will compile and run. New problem you'll see is the
Yellow Screen Of Death with the something like this: 'Object with id: 1 was not of the specified sublcass: N2.ContentItem (Discriminator was: 'StartPage0') '. That's NHibernate compalining that it cannot resolve records in the dabase to any
.Net types visible to it in all assemblies within your App Domain. So now it's time to some creative moves:
3. Look into ~/Models folder, examine non-abstract classes there: when NHibernate retrieves records from
n2Item table, it looks into Type field and tries to find a corresponding .Net class either by it's name, -OR- if class is decorated with [Definition] attribute, then by attribute's second parameters. E. g. there's ContentPage
class, decorated with [Definition("Content Page", "Test")] -- then you'll need to put value 'Test' into
Please tell how it will go,
Good luck !
Thanks for your help - I've got the project up and running now. I had to add a load of classes to the models directory (one for each distionct 'type' field value in
n2Item in the db as outlined above). At the moment they all inherit from "AbstractPage" which I am fairly confident is wrong but I shall investigate further tomorrow in an effort to get everything cleared up.