1

I have a solution with the following projects:

  • App.Web.Private - Administration web interface.
  • App.Web.Public - End-user public interface.
  • App.Web.Core - Commons for both private and public interfaces.

I would like to know how can I separate my models from public and private web interfaces and put them into App.Web.Core?

I tried adding the namespaces in web.config, but seems not to work correctly, I always get a missing assembly reference...

Update

Note: both private and public interface are referencing App.Web.Core. The question is related to this strange behavior although the references are done but the project can't see it. As I mentioned on the original question, I also added the references in both web.config.

Update 2

This is a screenshot of the error: error

Rubens Mariuzzo
  • 28,358
  • 27
  • 121
  • 148
  • 2
    That's a pretty self-explanatory error message: you moved the models to the other project, so the project that's trying to *use* the models needs a reference to that assembly that *contains* the models. – anaximander Feb 12 '13 at 15:11
  • I understood the message, the problem is that the project where the models are is already referenced... – Rubens Mariuzzo Feb 12 '13 at 15:24
  • So, is this a compile time error, or a runtime error? – scott-pascoe Feb 12 '13 at 15:27
  • It is are runtime error. – Rubens Mariuzzo Feb 12 '13 at 15:27
  • I assume you are getting a Yellow screen error message on this, would it be possible to let us see that message? – scott-pascoe Feb 12 '13 at 15:30
  • @scott-pascoe, screenshot added. – Rubens Mariuzzo Feb 12 '13 at 15:33
  • Try adding, in the razor view an @Using ...models at the top. This should validate that you've got the right physical stuff arranged. If it succeeds, then I would go back and look at the added reference in the web.config and make sure it doesn't have a typo. – scott-pascoe Feb 12 '13 at 15:34
  • I added the `@using`, but the problem persist. The autocomplete, let me reference the namespace from the external assembly, but the runtime exception still the same. – Rubens Mariuzzo Feb 12 '13 at 15:36
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/24386/discussion-between-scott-pascoe-and-rubens-mariuzzo) – scott-pascoe Feb 12 '13 at 15:37
  • Please post your the namespace section of your `~/web.config` and `~/Views/web.config` – Omar Feb 12 '13 at 15:41

4 Answers4

4

Try adding @using App.Web.Core to the top of the view. If that works, then you'll know you've got the physical stuff right. Then go check for typos.

Rubens Mariuzzo
  • 28,358
  • 27
  • 121
  • 148
scott-pascoe
  • 1,463
  • 1
  • 13
  • 31
2

In your solution, right click referenced, add App.Web.Core

Dave Alperovich
  • 32,320
  • 8
  • 79
  • 101
2

In Visual Studio 2010:

  • Right click on "References" and click on "Add Reference...".
  • Choose the App.Web.Core project and click "Ok".

Now when you want to use these models from App.Web.Core you also need to add an using statement at the top of your class.

Example: using App.Web.Core.Models;

  • Thanks, but I have hundreds of razor files... and I already have other references (from same assembly of the web project) in web.config that I can use without writing `using`. – Rubens Mariuzzo Feb 12 '13 at 15:30
  • 1
    Maybe this is something you're looking for: http://stackoverflow.com/questions/4953330/razor-based-view-doesnt-see-referenced-assemblies –  Feb 12 '13 at 15:43
1

Check the version of .Net against which the Public and Private project have been build. Project Core may be on an older version of .Net and Public and Private on a new.

To check the version open project properties page and verify.

Chandermani
  • 42,589
  • 12
  • 85
  • 88