我在.dll的发布版本上运行了peverify,它给出了错误"Stack depth根据路径不同“:
[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.dllset_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");
}
}
}我不知道为什么这个错误只出现在发布版本中。
发布于 2015-03-13 11:50:58
虽然可能与OP的问题没有直接关系,但我也遇到了这个错误。我正在生成用于反序列化HashSet<T>的IL代码-问题是计算堆栈不平衡,因为HashSet<T>中的Add方法返回布尔值,而不是空值。所以调用它会推送一个我并不关心的布尔值。在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();https://stackoverflow.com/questions/25127576
复制相似问题