CS0246: The type or namespace name "ProductDto" could not be found(are u missing a using directive or an assembly reference?)

2022-06-24T15:28:07.417+00:00

hey anyone give me the solution of this issue https://github.com/GavinLonDigital/ShopOnlineSolution/issues/1

ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
4,157 questions
Blazor
Blazor
A free and open-source web framework that enables developers to create web apps using C# and HTML being developed by Microsoft.
1,385 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,234 questions
{count} votes

3 answers

Sort by: Most helpful
  1. SurferOnWww 1,906 Reputation points
    2022-06-25T00:51:49.52+00:00

    I guess that you copied the source code written by somebody else and the definition of ProductDto class is included somewhere else. If so please find the source code that include the definition of ProductDto class.

    I understand that the Dto stands for Data Transfer Object as described in the following Microsoft document:

    Create Data Transfer Objects (DTOs)
    https://learn.microsoft.com/en-us/aspnet/web-api/overview/data/using-web-api-with-entity-framework/part-5

    It is likely defined in a separate .cs file.

    0 comments No comments

  2. Zhi Lv - MSFT 32,011 Reputation points Microsoft Vendor
    2022-06-27T06:09:31.877+00:00

    Hi @DEBASIS PAUL (Zhýralý Pāvils) #BlackLivesMatter ,

    CS0246: The type or namespace name "ProductDto" could not be found(are u missing a using directive or an assembly reference?)

    If you check the Yotube video or check the source code, you can see that in the solution, there have three projects: ShopOnline.Api, ShopOnline.Models and ShopOnline.Web.

    The ProductDto class was in the ShopOnline.Models project, and in the ShopOnline.Api and ShopOnline.Web project, they will add the ShopOnline.Models project reference.
    For example, in the ShopOnline.Web project, right click the Dependencies option => click the Add Project Reference... => in the popup window select the ShopOnline.Models project => Finally, click the Ok button. Then, in the ShopOnline.Web project, you can add the ShopOnline.Models project reference:

     screenshot


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    Best regards,
    Dillion

    0 comments No comments

  3. satya karki 986 Reputation points MVP
    2022-06-27T07:17:16.863+00:00

    Hi, Check your Web(ShopOnline.Web) project references and add the Model project in the references. Maybe you are missing to add model project (ShopOnline.Models) in ShopOnline.Web project.

    0 comments No comments