本文介绍了获取WPF项目的项目名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在写我的第一个WPF应用程序,而我试图让该项目的名称,这样我就可以输出。但是,使用
Assembly.GetEntryAssembly()的GetName()或
Assembly.GetExecutingAssembly()。的GetName()让我的名字以及版本号(即DataPusher,版本= 2.0.466.16967)。
有没有办法只得到大会的名字吗?谢谢。
解决方案 字符串名称= Assembly.GetEntryAssembly()的GetName()名称。或
字符串名称= Assembly.GetExecutingAssembly()的GetName()名称。
另外,你可以得到大会对象从装配任何已知类型:
装配总成= typeof运算({类的名字在这里})大会。这也允许另一种选择,以获得该名称:
字符串名称= typeof运算({类的名字在这里})Assembly.GetName()名称。
I'm writing my first WPF application, and I'm trying to get the name of the project so I can output it. However, using
Assembly.GetEntryAssembly().GetName()or
Assembly.GetExecutingAssembly().GetName()gets me the name as well as the version number(i.e., DataPusher, Version=2.0.466.16967).
Is there a way to get ONLY the assembly name? Thanks.
解决方案 string name = Assembly.GetEntryAssembly().GetName().Name;or
string name = Assembly.GetExecutingAssembly().GetName().Name;Alternatively, you can get the Assembly object from any known type in the assembly:
Assembly assy = typeof({class name here}).Assembly;This also allows another option to get the the name only:
string name = typeof({class name here}).Assembly.GetName().Name;
更多推荐
获取WPF项目的项目名称
发布评论