How to access a type with same fully qualified nam

2019-07-31 22:19发布

I need to refer to both the assemblies PresentationFramework.Classic and PresentationFramework.Luna and I have a situation where I need to use the Microsoft.Windows.Themes.DataGridHeaderBorder type. But this gives error as both the assemblies have this type defined. I mean, I can do with referring to any of them (Classic or Luna) for this type, it's just a simple Datagrid, where I need to check if the DataGridHeaderBorder is clicked.

Thanks in advance.

2条回答
贼婆χ
2楼-- · 2019-07-31 22:51

Try this:

using Clasic = PresentationFramework.Classic;
using Luna = PresentationFramework.Luna;



namespace Test1
{
    class Program
    {
        static void Main(string[] args)
        {
            Clasic.Microsoft.Windows.Themes.DataGridHeaderBorder bClassic;
            Luna.Microsoft.Windows.Themes.DataGridHeaderBorder bLuna;
        }
    }
}
查看更多
萌系小妹纸
3楼-- · 2019-07-31 23:03

This is the sort of situation that external assembly aliases are intended to address. You can also specify the alias for a reference using the "Aliases" property in the reference's properties sheet in Visual Studio if command line compilation isn't your thing. See http://blogs.msdn.com/b/ansonh/archive/2006/09/27/774692.aspx for a full example.

查看更多
登录 后发表回答