简体   繁体   English

不断收到部分声明可访问性方法错误

[英]Keep getting partial declarations accessibillity method errors

I have downloaded some code from my friend (we are working together on it) when I run the code a few times, it runs fine with no errors, then later when I go to run it, I keep getting these 2 errors: 当我几次运行代码时,我已经从我的朋友处下载了一些代码(我们正在一起工作),它可以正常运行且没有错误,然后稍后运行它时,我不断遇到这两个错误:

Error 1 Partial declarations of 'GuiGame.HareAndTortoiseForm' have conflicting accessibility modifiers 错误1'GuiGame.HareAndTortoiseForm'的部分声明具有可访问性修饰符冲突

public partial class HareAndTortoiseForm : Form {

Error 2 Missing partial modifier on declaration of type 'GuiGame.HareAndTortoiseForm'; 错误2声明类型'GuiGame.HareAndTortoiseForm'时缺少部分修饰符; another partial declaration of this type exists 存在这种类型的另一部分声明

internal class HareAndTortoiseForm {

I think the code was generated automatically when I created the GUI form. 我认为代码是在创建GUI表单时自动生成的。 I have tried changing the accessors so they are both public partial, but still no luck. 我尝试过更改访问器,以使它们都属于公共部分,但仍然没有运气。 I have tried re-downloading the file about 10 times and keep having the problem, I cannot find out where it is coming from or how to fix it. 我尝试重新下载该文件约10次,并一直遇到问题,我无法确定它来自何处或如何修复。 Does anyone have any clue? 有人有任何线索吗? The top line of code is from the HareAndTortoiseForm.cs class and the other line is from the HareAndTortoiseForm1.Designer.cs class. 代码的第一行来自HareAndTortoiseForm.cs类,另一行来自HareAndTortoiseForm1.Designer.cs类。

So long as the two match, it should be fine. 只要两个匹配,就可以了。 If they're really both public, it will work... but I suspect you're modifying the code owned by the designer... which is then regenerating it to be internal. 如果它们确实是公开的,那么它将起作用……但是我怀疑您正在修改设计者拥有的代码……然后将其重新生成为内部代码。

If you want it to be public, go to the form designer and change the accessibility there to Public, at which point it should be fine. 如果要使其公开,请转到表单设计器并将那里的可访问性更改为“公开”,此时应该可以。

If you want it to be internal, change your "manual" code file and just fix it there. 如果您希望它位于内部,请更改“手动”代码文件,然后在此处进行修复。

So long as it's consistent between the source files and the designer doesn't then overwrite the source with something conflicting, all should be well. 只要在源文件之间保持一致并且设计者就不会以冲突的方式覆盖源,那么一切都应该很好。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM