Search code examples
c#asp.netreferencescaffolding

Object referencing across projects in same solution


I had a solution that contained two projects, one for the web layer that also contained the models, and another for a Windows forms project that did some other "stuff". The forms project referenced the web project, and all was fine up until I needed to reference something from the web project in the forms project, which I could not do for circular reference reasons.

So I created a new solution, put the data layer in one project and the web layer in another, so later on I could add the third project, and put in the references I need. Now when I run the web project, I get the following error;

enter image description here

So I understand that the web project is struggling to find my namespace from the data project, but I have referenced it, so I don't know what more to do.

***EDIT This comes as no shock, but it's the view that's the issue. If I edit my Index.cshtml, it recognises the referenced project. I tried adding;

@using LottoData.Models

and intellisense completed as I typed. However, when I run it now, I get;

enter image description here

Help!


Solution

  • This was my bad. I forgot to change the output type for the data project to "Class Library", it was still set to "Console Program". Changed that, removed and re-added the reference, cleaned and rebuilt and it works fine now. Thanks @David and @Armand for your input.