Skip to content

References between Projects independence #12

@hongquan09dth5

Description

@hongquan09dth5

Hi Neil,

First of all, I'm so naive about dotnetcore, I just was into it for one month.

My problem was I've seen you only added Infrastructure project references into API project. It means API only depends on Infrastructure, but what am I seeing that you were able to use the Core project's functionality or models on API project.

For example, In BasketController, you addded:

using Core.Entities;
using Core.Interfaces;

It's too weird, because I was not able to do it as well as you did.

I've checked your API.csproj and maked sure you only added Infrasctructure references and it exactly was:

your API.csproj

<ItemGroup>
    <ProjectReference Include="..\Infrastructure\Infrastructure.csproj"/>
  </ItemGroup>

I only can do the same thing if I did add Core references into API project as well:

my API.csproj

 <ItemGroup>
    <ProjectReference Include="..\Infrastructure\Infrastructure.csproj" />
    <ProjectReference Include="..\Core\Core.csproj" />
  </ItemGroup>

I ignored the issue for this Section 3, but I did notice it again as studying in Section 13 during I tried to setup the connection string for Redis in Startup.cs. I was not able to print up the StackExchange.Redis, because in previous step you just added the Redis package in Infrastructure project but API porject. it's big surprised again for me, how can you use the Redis namespace in API project :

Startup.cs

using StackExchange.Redis;

but I got the error when I added this namespace. It only worked if I must to install package in both API and Infrastructure.

Did I setup something incorrectly?

Here are my dotnet information:

`
Runtime Environment:
OS Name: Windows
OS Version: 10.0.19042
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\5.0.301\

Host (useful for support):
Version: 5.0.7
Commit: 556582d964

.NET SDKs installed:
5.0.301 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
Microsoft.AspNetCore.App 3.1.16 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 5.0.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 3.1.16 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 5.0.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 3.1.16 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 5.0.7 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
`

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions