Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Missing partial modifier on declaration of type 'x' - cause by auto-generated code by designer

The full error description is as per below:

enter image description here

And I found a few similar question posted before: A and B

But the question in A and B does not provide detail of problem description (perhaps we prompted the same error message but caused by different reason? I am not sure..). Any how, answer in A and B does not have good solution. So I decided to post the similar question with some more details.

My problem is as per below:

The Designer auto generate a new code (ErrSer1.Designer) which contain the same partial class name in (ErrSer.Designer). [Shown in printScreen_1 -> line 25 ]

The difference as we can see is, one is in ErrSer1.Designer (the extra auto generated one)

internal class ErrSer

Another one is in ErrSer.Designer (the original one who suppose to be)

partial class ErrSer

Here is the printScreen_1 to show ErrSer1.Designer (the extra auto-generated one) [ Notice line 25 ]

enter image description here

And here is the printScreen_2 to show ErrSer.Designer (the original and usual one) [ Notice line 3 ]

enter image description here

Lastly... what can I do to solve this annoying auto-generated code problem?

EDIT1: My ErrSer Form declared like this

public partial class ErrSer : Form

EDIT2: My .csproj file

My .csproj file location

like image 604
jhyap Avatar asked Apr 02 '13 00:04

jhyap


2 Answers

You (accidentally) have set the "Custom Tool" property for "ErrSer.resx" file to "ResXFileCodeGenerator". So Visual Studio generates a redundant source file for that file.

To solve the problem, open Solution explorer, then in "FormFile" folder expand "ErrSer.cs" node. Right-click the "ErrSer.resx" file and select "Properties". In the properties window clear the value of "Custom Tool" property:

Solution Explorer and Properties windows

Clear the specified value then build the project.

like image 152
Mohammad Dehghan Avatar answered Nov 20 '22 18:11

Mohammad Dehghan


Your problem is that you have one Form named ErrSer and one resource file named ErrSer with a custom tool set. There are only two conditions comes to my mind for this case to happen

  1. You have a form and you accidentally set Custom Tool property on that file, so even if you do not need it to be generated and a ErrSer.Designer.cs file is generated for your resources.

  2. You have a form and you have created a ResX with same name.

For the first case just remove Custom Tool property on ResX file and generated Designer file. For the second case, rename your ResX file.

like image 36
Erdogan Kurtur Avatar answered Nov 20 '22 18:11

Erdogan Kurtur