Troubleshooting Errors

I downloaded some code from my friend (we work together on it), when I run the code several times, it works fine, without errors, and then when I go to run it, I keep getting these 2 errors:

Error 1 Partial "GuiGame.HareAndTortoiseForm" declarations have conflicting accessibility modifiers

public partial class HareAndTortoiseForm : Form { 

Error 2 There is no partial modifier when declaring type 'GuiGame.HareAndTortoiseForm'; there is another partial declaration of this type

 internal class HareAndTortoiseForm { 

I think the code was generated automatically when I created the GUI form. I tried changing the accessory to be public, but still no luck. I tried to reload the file about 10 times and you had a problem, I can’t find out where it came from or how to fix it. Somebody knows? The top line of code is for the HareAndTortoiseForm.cs class, and the other is for the HareAndTortoiseForm1.Designer.cs class.

+4
source share
1 answer

As long as they match, everything should be fine. If they are really public, it will work ... but I suspect that you are modifying the code belonging to the designer ... which then regenerates it as internal.

If you want it to be publicly accessible, go to the form designer and change the accessibility to it in Public, after which it will be fine.

If you want it to be internal, change your "manual" code and just fix it there.

As long as it is not consistent between the source files and the constructor, it does not overwrite the source with something contradictory, everything should be fine.

+2
source

Source: https://habr.com/ru/post/1483940/


All Articles