使用 Linq 方法会导致 WindowsBase 中缺少对 DependencyObject 的引用
我有一些 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我通过在应用程序中添加对 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.