0

我在peverify.dll 的发布版本上运行,它给了我错误“堆栈深度因路径而异”:

[IL]: Error: [C:\tfs\EcoSys\SCM\NextGenInstaller\Cmc.Installer\Cmc.Installer.Desktop\bin\Release\Cmc.Installer.Modules.Crm.dll : Cmc.Installer.Modules.Crm.Models.DatabaseInfo::set_Action][offset 0x0000007F] Stack depth differs depending on path.
1 Error(s) Verifying C:\tfs\EcoSys\SCM\NextGenInstaller\Cmc.Installer\Cmc.Installer.Desktop\bin\Release\Cmc.Installer.Modules.Crm.dll

的代码set_Action如下:

public InstallerAction Action
{
    get { return _action; }
    set
    {
        _action = value;

        InstallMainServer = false;
        InstallDistributorServer = false;
        InstallAnalyticsServer = false;
        InstallMediaServer = false;
        InstallWebTrakServer = false;

        switch (DatabaseType)
        {
            case DatabaseType.Main:
                InstallMainServer = (Action == InstallerAction.Install);
                break;
            case DatabaseType.Distributor:
                InstallDistributorServer = (Action == InstallerAction.Install);
                break;
            case DatabaseType.Analytics:
                InstallAnalyticsServer = (Action == InstallerAction.Install);
                break;
            case DatabaseType.Media:
                InstallMediaServer = (Action == InstallerAction.Install);
                break;
            case DatabaseType.WebTrak:
                InstallWebTrakServer = (Action == InstallerAction.Install);
                break;
            default:
                throw new ArgumentOutOfRangeException("DatabaseType");
        }
    }
}

我不知道为什么这个错误只发生在发布版本中。

4

1 回答 1

1

虽然可能与 OP 的问题没有直接关系,但我也遇到了这个错误。我正在生成用于反序列化的 IL 代码HashSet<T>- 问题是评估堆栈不平衡,因为Add方法HashSet<T>返回一个布尔值,而不是 void。所以调用它会推送一个我不关心的布尔值。在 Add调用Pop后立即调用解决了问题。

            //T x; Deserialize(stream, out x, ctx);
            var x = emit.declocal(elementType);
            emit.ldarg_0()
                .ldloca_s(x)
                .ldarg_2()
                .call(deserialize);

            //value.Add(x);
            emit.ldarg_1()
                .ldind_ref()
                .ldloc_s(x)
                .call(add) // returns bool, since we're not using the value we need to pop the stack to keep the balance
                .pop();
于 2015-03-13T03:50:57.550 回答