获取WPF项目的项目名称

编程入门 行业动态 更新时间:2024-10-23 19:29:23
本文介绍了获取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项目的项目名称

本文发布于:2023-11-22 20:47:49,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1618963.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:项目   名称   WPF

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!