使用 Linq 方法会导致 WindowsBase 中缺少对 DependencyObject 的引用

发布于 2024-09-05 13:06:09 字数 458 浏览 1 评论 0原文

我有一些 c# 源代码,我想在我的应用程序中使用 CodeDom 进行编译(对于插件)

一切正常,除非我在某些集合上使用 Linq 扩展函数

var dict = new Dictionary<KeyType, ValueType>();
....
dict.Any(KV=>KV.Key == "Some Key");

当我尝试编译包含此代码的源代码时,它会出现 CodeDom抱怨我缺少对 WindowsBase 中 DependencyObject 的引用。

我不明白为什么会发生这种情况。 Dictionary 类或 Any 扩展方法都没有引用该类,它显然是 Windows.Forms 的一部分,

我通常会忽略这个怪癖,让 CodeDom 添加引用并继续,但显然 WindowsBase 是特殊的并且并不总是分布式的我不想给可能没有正确安装它的用户带来问题。

I have some c# source that I want to compile using CodeDom within my application (for a plugin)

Everything works fine, except if I use a Linq extension function on some of my collections

var dict = new Dictionary<KeyType, ValueType>();
....
dict.Any(KV=>KV.Key == "Some Key");

When I try to compile source that has this code, it CodeDom complains that I am missing a reference to DependencyObject in WindowsBase.

I do not understand why this is happening. Neither the Dictionary class, or the Any extension method reference that class, which apparently is part of Windows.Forms

I would normally just ignore the quirk, make the CodeDom add a reference and move on, but Apparently WindowsBase is special and is not always distributed and I don't want to cause issues for users that may not have it installed correctly.

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

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

发布评论

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

评论(1

小…红帽 2024-09-12 13:06:09

我通过在应用程序中添加对 WindowsBase 的引用并将其设置为始终复制来解决了眼前的问题。然后我就能够正确添加 codeDom 中的引用。

我仍然对为什么需要 DLL 感到困惑,但我已经解决了它。

I solved the immediate problem by adding a reference to WindowsBase in my application, and setting it to always copy. Then I was able to add the reference in codeDom correctly.

Im still confused as to why the DLL is needed, but I have worked around it.

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