6

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

public partial class HareAndTortoiseForm : Form {

Error 2 Missing partial modifier on declaration of type '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. 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. 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.

4

1 回答 1

3

只要两者匹配,应该没问题。如果他们真的都是公开的,它会工作......但我怀疑你正在修改设计师拥有的代码......然后将其重新生成为内部代码。

如果您希望它公开,请转到表单设计器并将那里的可访问性更改为公开,此时应该没问题。

如果您希望它是内部的,请更改您的“手动”代码文件并在那里修复它。

只要源文件之间是一致的,并且设计者不会用冲突的东西覆盖源,一切都应该很好。

于 2013-06-01T13:20:44.967 回答