How to get the assembly name and class name with full namespace of a given class in the solution?

前端 未结 4 1423
耶瑟儿~
耶瑟儿~ 2021-01-02 10:33

I\'m working with WPF and often have the need to get the namespace and assembly name of a given class. But I don\'t know how to do this.

So, how can we get the name

4条回答
  •  半阙折子戏
    2021-01-02 10:45

    You can use F# interative, just open the window (View -> Other Windows -> F# Interactive) and try the following:

    > typedefof.Assembly.FullName;;
        val it : string =
          "System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
    

    There are a few assemblies referenced automatically like System. If you need to get the name from another assembly, you'll need to add the reference first (like the service model for example).

    > #r "System.ServiceModel.dll";;
    
    --> Referenced 'C:\Windows\Microsoft.NET\Framework\v4.0.30319\System.ServiceModel.dll'
    
    > typedefof.Assembly.FullName;;
    val it : string =
      "System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
    

    F# interative is part of Visual Studio 2010.

提交回复
热议问题