需要默认访问器:自定义配置部分

发布于 2024-10-10 09:27:38 字数 605 浏览 0 评论 0原文

我对一个简单的微软错误消息感到非常困惑。

当我针对包含自定义 ConfigurationSection 的程序集(该程序集又使用自定义 ConfigurationElement 和自定义 ConfigurationElementCollection,以及多个 ConfigurationProperties)运行 XSD.exe 时,我收到以下错误消息:

错误:处理“Olbert.Entity.Utils.dll”时出错。

  • 反映类型“Olbert.Entity.DatabaseConnection”时发生错误。
  • 您必须在 System.Configuration.ConfigurationLockCollection 上实现默认访问器,因为它继承自 ICollection。

然而,相关类有一个默认访问器:

public object this[int idx]
{
    get { return null; }
    set { }
}

我意识到上面没有执行任何操作,但我不需要通过索引访问元素的属性。我只是想解决该错误消息。

那么到底是怎么回事呢?

I am totally confused by a simple Microsoft error message.

When I run XSD.exe against an assembly that contains a custom ConfigurationSection (which in turn utilizes a custom ConfigurationElement and a custom ConfigurationElementCollection, as well as several ConfigurationProperties), I get the following error message:

Error: There was an error processing 'Olbert.Entity.Utils.dll'.

  • There was an error reflecting type 'Olbert.Entity.DatabaseConnection'.
  • You must implement a default accessor on System.Configuration.ConfigurationLockCollection because it inherits from ICollection.

Yet the class in question has a default accessor:

public object this[int idx]
{
    get { return null; }
    set { }
}

I realize the above doesn't do anything, but I don't need to access the element's properties by index. I'm just trying to work around the error message.

So what's going on?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

自演自醉 2024-10-17 09:27:38

放下一个;在集合访问器中。放 { ; }

drop a ; in the set accessor. set { ; }

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文