Class is inaccessible due to its protection level

后端 未结 9 1816
孤街浪徒
孤街浪徒 2020-12-07 01:00

I have three classes. all are part of the same namespace. here are the basics of the three classes.

//FBlock.cs
namespace StubGenerator.PropGenerator
{
    c         


        
相关标签:
9条回答
  • 2020-12-07 01:09

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

    0 讨论(0)
  • 2020-12-07 01:10

    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.

    0 讨论(0)
  • 2020-12-07 01:15

    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.

    0 讨论(0)
  • 2020-12-07 01:18

    your class should be public

    public class FBlock : IDesignRegionInserts, IFormRegionInserts, IAPIRegionInserts, IConfigurationInserts, ISoapProxyClientInserts, ISoapProxyServiceInserts

    0 讨论(0)
  • 2020-12-07 01:32

    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.

    0 讨论(0)
  • 2020-12-07 01:33

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

    [Serializable()]
    public partial class Class
    {
    
    0 讨论(0)
提交回复
热议问题