相关疑难解决方法(0)

如何确定给定.NET程序集使用的子系统?

在C#应用程序中,我想确定另一个.NET应用程序是否是控制台应用程序.

可以使用反射API完成吗?

编辑:好的,看起来我不会得到这个问题的好答案,因为它看起来不像框架暴露我想要的功能.我在PE/COFF规范中挖掘并提出了这个:

/// <summary>
/// Parses the PE header and determines whether the given assembly is a console application.
/// </summary>
/// <param name="assemblyPath">The path of the assembly to check.</param>
/// <returns>True if the given assembly is a console application; false otherwise.</returns>
/// <remarks>The magic numbers in this method are extracted from the PE/COFF file
/// format specification available from http://www.microsoft.com/whdc/system/platform/firmware/pecoff.mspx
/// </remarks>
bool AssemblyUsesConsoleSubsystem(string assemblyPath)
{
    using (var s = new FileStream(assemblyPath, FileMode.Open, FileAccess.Read))
    {
        var rawPeSignatureOffset = …
Run Code Online (Sandbox Code Playgroud)

c# reflection

5
推荐指数
1
解决办法
840
查看次数

标签 统计

c# ×1

reflection ×1