ERROR: The name '' does not exist in the current context

Donald Symmons 3,066 Reputation points
2022-12-15T00:48:53.397+00:00

I am having these much errors in my project, as I recently created a new project in Visual Studio 2022
those names actually exists in the client side, they are names to Label controls, ImageFileUploads, and Gridview control. So what could be the problem, what did I miss out?

270666-1554-errors.png

I really don't know what to do. It was easy in the older versions of visual studio all these things did not happen; it was easy to cteate a new peoject.
What should be done to make these errors go away?

Developer technologies | .NET | Other
Developer technologies | ASP.NET | Other
Developer technologies | C#
{count} vote

Accepted answer
  1. Lan Huang-MSFT 30,191 Reputation points Microsoft External Staff
    2022-12-15T06:46:09.267+00:00

    Hi @Donald Symmons ,

    The type 'System.Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.

    First you need to download System.Runtime.dll through the nuget package manager(Tools-->NuGet Package Manager), then add: using System.Runtime; to aspx.cs.
    270832-image.png
    If you still report errors, please add the assembly to web.config. Other assembly errors can refer to this method.

    <compilation debug="true" targetFramework="4.5">  
      <assemblies>       
        <add assembly="System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />     
      </assemblies>  
    </compilation>  
    

    Maybe I need to change the namespace in all the pages at page level in the Inherits attribute and code behind file.

    Yes you do, you need to change all your old project names to the new ones (quirverapp), you can use (Ctrl+F) to search for any missing project names.

    Best regards,
    Lan Huang


    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.

    0 comments No comments

0 additional answers

Sort by: Most helpful

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.