我在我的应用程序中定义了一些表达式变量,需要引用Microsoft.Scripting.Core。 该程序集包含与主要.Net框架中的System.Core程序集相同的名称空间。
我想使用System.Core程序集的定义,因为它是稳定的,而Microsoft.Scripting.Core是alpha。
如何告诉我的应用程序优先使用System.Core中的System.Linq.Expressions命名空间而不是Microsoft.Scripting.Core,但是仍然能够保留对它的引用?
I am defining some Expression variables in my app and need to have a reference to Microsoft.Scripting.Core. That assembly includes the same namespace as the System.Core assembly from the main .Net framework.
I want to use the defintions from the System.Core assembly as it's stable whereas the Microsoft.Scripting.Core is alpha.
How do I tell my app to preference the System.Linq.Expressions namespace in System.Core instead of Microsoft.Scripting.Core but still be able to keep the reference to it?
最满意答案
正如马克所说,这不是非常好 - 但外部别名是要走的路。
在解决方案资源管理器的“参考”部分中,选择System.Core程序集,转到属性。 将“Aliases”属性更改为包含“syscore”,例如
Aliases: global,syscore然后,在要使用System.Linq.Expressions的任何文件的顶部,键入:
extern alias syscore; using syscore::System.Linq.Expressions;这是丑陋的,但至少有可能:)
作为一个告诫,在扩展方法和外部别名方面,我已经看到了一些问题, 正如这个问题所描述的那样 。
As Marc says, it's not terribly nice - but extern aliases are the way to go.
In the "References" part of solution explorer, select the System.Core assembly, go to properties. Change the "Aliases" property to include "syscore", e.g.
Aliases: global,syscoreThen at the top of any file where you want to use System.Linq.Expressions, type:
extern alias syscore; using syscore::System.Linq.Expressions;It's ugly, but at least it's possible :)
As a caveat, I've seen some problems when it comes to extension methods and extern aliases, as described in this question.
更多推荐
发布评论