How can I qualify a .NET type with assembly name for Visual Studio debugger to disambiguate while using an ambiguous type?

前端 未结 3 1934
天命终不由人
天命终不由人 2021-02-20 10:30

I am using the VS debuggers \'Immediate Window\' to call a static API on a class which is an ambiguous type defined in 2 different assemblies.

The call fails with the fo

3条回答
  •  悲&欢浪女
    2021-02-20 10:57

    As Maslow suggests, it is possible to use reflection to get what you want. It's not pretty, though. For example, if you want to see the value of the static property My.Properties.Settings.Default, then assuming that MainWindow is some other type in the assembly (e.g. blah.dll) that contains the value you want to debug, this expression will get you the value:

    System.Reflection.Assembly
        .GetAssembly(typeof(MainWindow))
        .GetType("My.Properties.Settings")
        .GetProperty("Default")
        .GetValue(null)
    

    In this example, My.Properties.Settings is a type that is defined in two different assemblies.

    It's also possible to call methods etc. by using the appropriate tools from the System.Reflection namespace.

提交回复
热议问题