Class is inaccessible due to its protection level

人走茶凉 提交于 2019-11-28 01:49:30

First thing, try a full rebuild. Clean and build (or just use rebuild). Every once in a long while that resolves bizarre build issues for me.

Next, comment out the rest of the code that is not in your example you have posted. Compile. Does that work?

If so, start adding segments back until one breaks it.

If not, make all the classes public and try again.

If that still fails, maybe try putting the trimmed down classes in the same file and rebuilding. At that point, there would be absolutely no reason for access issues. If that still fails, take up carpentry.

There was a project that used linked files. I needed to add the method.cs file to that project as a linked file as well, since the FBlock.cs file was there. I've never heard of linked files before, I didn't even know that was possible.

Try adding the below code to the class that you want to use

[Serializable()]
public partial class Class
{

It may also be the case that the library containing the class in question is not properly signed with a strong name.

The code you posted does not produce the error messages you quoted. You should provide a (small) example that actually exhibits the problem.

All your classes are internal by default

Marking public did not do the trick.

Are you sure you do not have two classes named Method, and perhaps are including the wrong Method class?

I'm guessing public Method AddMethod(string aName) is defined on a public interface that FBlock implements. Consumers of that interface are not guaranteed to have access to Method.

Hi You need to change the Button properties from private to public. You can change Under Button >> properties >> Design >> Modifiers >> "public" Once change the protection error will gone.

Budi

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!