【问题标题】:Get executing assembly name from referenced DLL in MonoTouch?从 MonoTouch 中引用的 DLL 获取执行程序集名称?
【发布时间】:2013-05-07 05:52:01
【问题描述】:

我正在构建一个跨平台库,并且有时我想从 dll 中获取正在执行的程序集名称。

在我使用的窗口中:

System.AppDomain.CurrentDomain.FriendlyName

我得到类似“MyApp.exe”的东西

但是,这在单点触控中无法“按预期”工作。在 iOS 上运行时,它返回“MonoTouch”

有什么办法,使用可以在 windows、monotouch、monodroid 上编译的代码来获取正在执行的程序集名称?

【问题讨论】:

    标签: c# xamarin.ios xamarin


    【解决方案1】:

    试试这个:

    var path = System.Reflection.Assembly.GetExecutingAssembly ().Location;
    var name = System.IO.Path.GetFileName (path);
    

    【讨论】:

    • System.Reflection.Assembly.GetExecutingAssembly().Location 返回 .dll 位置。我想获取可执行文件名称,即引用 dll 的名称。 (Windows 中的 .exe,iOS 中的 .app)
    • 然后使用 GetEntryAssembly()。
    • 感谢 Rolf,GetEntryAssembly 完成了这项工作
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-03-24
    • 2018-07-09
    • 1970-01-01
    • 1970-01-01
    • 2012-01-14
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多