question

DimitrisGkikas-1236 avatar image
0 Votes"
DimitrisGkikas-1236 asked YijingSun-MSFT answered

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

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; } }`




dotnet-csharpdotnet-aspnet-mvc
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Your sample code above shows you used the same variable name "GeneralFormConfiguration" within a class. Class member names must be unique.

If you have checked your code and the class names are unique then try cleaning the solution. Right click the solution and select "Clean Solution". Next, build the solution.

0 Votes 0 ·

1 Answer

YijingSun-MSFT avatar image
0 Votes"
YijingSun-MSFT answered

Hi @DimitrisGkikas-1236 ,
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.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.