由设计师自动生成的代码的原因 - 缺少类型的“X”部分的声明修饰符 [英] Missing partial modifier on declaration of type 'x' - cause by auto-generated code by designer

查看:670
本文介绍了由设计师自动生成的代码的原因 - 缺少类型的“X”部分的声明修饰符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

完整的错误说明是按照如下:

The full error description is as per below:

和我发现贴几个类似的问题之前:的一个和的

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

但在A和b的问题不提供问题描述细节(也许我们提示了同样的错误消息,但由不同的原因造成的?我不知道。)。任何如何,答案在A和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.

我的问题是按照如下:

设计器自动生成一个新的代码(ErrSer1.Designer),它包含(ErrSer.Designer)相同部分的类名。中所示的printScreen_1 - >在线25]

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 ]

我们可以看到不同的是,一个是在ErrSer1.Designer(额外的自动生成的一个)

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

内部类ErrSer

另外一个是在ErrSer.Designer (原一个谁假设是)

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

部分类ErrSer

下面是printScreen_1显示ErrSer1.Designer(额外的自动生成一个)[注意线25]

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

和这里是printScreen_2显示ErrSer.Designer(原和往常)通知行3]

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

最后...我能做些什么来解决这个恼人的自动生成的代码的问题?

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

EDIT1:
我ErrSer表格声明如下

My ErrSer Form declared like this

public partial class ErrSer : Form

EDIT2:
我的.csproj文件

My .csproj file

我的.csproj文件地点

推荐答案

您(意外),已为ErrSer.resx文件中的自定义工具属性为ResXFileCodeGenerator。因此Visual Studio生成该文件冗余源文件。

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.

要解决这个问题,打开解决方案资源管理,然后在FormFile文件夹中依次展开ErrSer.cs节点。右键单击ErrSer.resx文件,并选择属性。在属性窗口中清除自定义工具属性的值:

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:

解决方案资源管理器和属性窗口

清除指定的值,则生成项目。

Clear the specified value then build the project.

这篇关于由设计师自动生成的代码的原因 - 缺少类型的“X”部分的声明修饰符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆