CS0102 The type 'SystemController.ViewsClass' already contains a definition for 'GeneralFormConfiguration'

Dimitris Gkikas 1 Reputation point
2021-08-20T09:59:50.307+00:00

After a retargeting from .NET 4.5 to 4.0 and back to 4.0 I got this error (3 times in the same file for different classes)
Probably a duplicate but I am not sure how to solve it.
Do I have to rename the class? And if yes, how?

Code:` public readonly string GeneralFormConfiguration = "~/Views/System/GeneralFormConfiguration.cshtml";

            static readonly _GeneralFormConfigurationClass s_GeneralFormConfiguration = new _GeneralFormConfigurationClass();
            public _GeneralFormConfigurationClass GeneralFormConfiguration { get { return s_GeneralFormConfiguration; } }`
ASP.NET
ASP.NET
A set of technologies in the .NET Framework for building web applications and XML web services.
3,272 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,277 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Yijing Sun-MSFT 7,066 Reputation points
    2021-08-23T06:42:21.427+00:00

    Hi @Dimitris Gkikas ,
    Your problem's meaning is a class contains multiple declarations of identifiers with the same name in the same scope.
    To fix the error, please rename the duplicate identifier.You could refer to the following simple example:

     public class MyClass  
        {  
                static readonly _GeneralFormConfigurationClass s_GeneralFormConfiguration = new _GeneralFormConfigurationClass();  
                public _GeneralFormConfigurationClass GeneralFormConfiguration{ get { return s_GeneralFormConfiguration; } }  
                public void GetString()  
                {  
                    string GeneralFormConfiguration = "~/Views/System/GeneralFormConfiguration.cshtml";  
                }  
        }  
    

    Best regards,
    Yijing Sun


    If the answer is helpful, please click "Accept Answer" and upvote it.

    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