Public Class - “is inaccessible due to its protection level. Only public types can be processed.”

前端 未结 1 1885
面向向阳花
面向向阳花 2021-02-19 03:18

I am doing a test project to learn about XML serialization of an object, and I am getting an odd runtime error:

namespace SerializeTest
{

public partial class F         


        
1条回答
  •  南方客
    南方客 (楼主)
    2021-02-19 03:58

    The Class is public

    No it's not. Here's the declaration:

    class Conn
    {
        ...
    }
    

    You haven't specified any access modifiers, so it's defaulting to internal (assuming it's non-nested). Just because it's got a public constructor doesn't make it public. You need to make it public explicitly:

    public class Conn
    {
        ...
    }
    

    0 讨论(0)
提交回复
热议问题