VisualStudio 2022 17.4.1 Throws the namespace" is a reserved word and cannot be used in implicit expressions. An explicit expression ("@()") must be used." build error in my _ViewImports.cshtml file.

Ajay Krishnan 1 Reputation point
2022-11-24T05:11:27.307+00:00

I have upgraded my Razor project to .netStandard2.1 to .net 6 after that I'm getting "namespace is a reserved word and cannot be used in implicit expressions. An explicit expression ("@()") must be used." build error in my _ViewImports.cshtml file. Same project doesn't throw any error in VisualStudio 2019 16.11.21 version but getting this build error in VisualStudio 2022 17.4.1

Developer technologies | ASP.NET | ASP.NET Core
Community Center | Not monitored
{count} votes

1 answer

Sort by: Most helpful
  1. Anonymous
    2022-11-25T02:58:42.193+00:00

    Hi @Ajay Krishnan ,

    264055-image.png

    As we discuss, the issue relates the "Microsoft.AspNetCore.MVC" package, this package is compatible with netStandard2.1 but not apply to .Net 6.
    So, after uninstalling the "Microsoft.AspNetCore.MVC" package, the application works.


    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

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.