How to resolve error CS1061?

Cindy See 206 Reputation points
2022-10-25T05:42:13.007+00:00

I have a data access layer and business object layer in my ASP.Net web application.
Everytime when I made changes to the existing function or added a new function in the data access layer and business object layer, it will throw error CS1061 when I build the solution. I think it is because the metadata of these files in the layer are locked and not reflecting the latest changes. How can I resolve or avoid this issue?

ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
4,544 questions
ASP.NET
ASP.NET
A set of technologies in the .NET Framework for building web applications and XML web services.
3,473 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,882 questions
Visual Studio Debugging
Visual Studio Debugging
Visual Studio: A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.Debugging: The act or process of detecting, locating, and correcting logical or syntactical errors in a program or malfunctions in hardware. In hardware contexts, the term troubleshoot is the term more frequently used, especially if the problem is major.
996 questions
0 comments No comments
{count} votes

Accepted answer
  1. Lan Huang-MSFT 29,251 Reputation points Microsoft Vendor
    2022-10-25T06:22:31.633+00:00

    Hi @Cindy See ,
    The CS1061 error is caused when you try to call a method or access a class member that does not exist.
    https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/compiler-messages/cs1061
    The following example generates CS1061 because Person does not have a DisplayName method. It does have a method that is called WriteName. Perhaps that is what the author of this source code meant to write.

    public class Person  
    {  
        private string _name;  
      
        public Person(string name) => _name = name;  
      
        // Person has one method, called WriteName.  
        public void WriteName()  
        {  
            System.Console.WriteLine(_name);  
        }  
    }  
      
    public class Program  
    {  
        public static void Main()  
        {  
            var p = new Person("PersonName");  
      
            // The following call fails because Person does not have  
            // a method called DisplayName.  
            p.DisplayName(); // CS1061  
        }  
    }  
    

    To correct this error

    1. Make sure you typed the member name correctly.
    2. If you have access to modify this class, you can add the missing member and implement it.
    3. If you don't have access to modify this class, you can add an extension method.

    When asking a question, you'd better provide a minimal reproducible example. so that we can better help you solve the problem.

    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 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.