gpt4 book ai didi

vb.net - 为什么 Visual Studio 2015 失败并显示错误代码 BC30506

转载 作者:行者123 更新时间:2023-12-02 10:42:39 33 4
gpt4 key购买 nike

我有一个非常大的项目,大约一个月前我已经从 Visual Studio 2012 转移到 2015。

代码是正确的。它编译了 99.9999% 的时间,除了最近两天我遇到了这种随机事件。

我正在使用混淆器(Eazfuscator 付费版)来构建解决方案。

在过去的两天里,我能够工作,所有的东西都一遍又一遍地编译并且工作得很好,但是当我以混淆模式编译项目时,有时,编译器会失败,并用错误列表填充以下内容:

Severity Code Description Project File Line Error
BC30506 Handles clause requires a WithEvents variable defined in the containing type or one of its base types. wRMS D:_Private\wRMS\wRMS_Miscellaneous Forms\Main Application\frmHome.vb 719 Error
BC30506 Handles clause requires a WithEvents variable defined in the containing type or one of its base types. wRMS D:_Private\wRMS\wRMS_Miscellaneous Forms\Main Application\frmUpdate.vb 5 Error
BC30506 Handles clause requires a WithEvents variable defined in the containing type or one of its base types. wRMS D:_Private\wRMS\wRMS_Miscellaneous Forms\Main Application\frmUpdate.vb 9 Error
BC30506 Handles clause requires a WithEvents variable defined in the containing type or one of its base types. wRMS D:_Private\wRMS\wRMS_Miscellaneous Forms\Main Application\frmUpdate.vb 13 Error
BC30506 Handles clause requires a WithEvents variable defined in the containing type or one of its base types. wRMS D:_Private\wRMS\wRMS_Miscellaneous Forms\Main Application\frmUpdate.vb 17 Error
BC30506 Handles clause requires a WithEvents variable defined in the containing type or one of its base types. wRMS D:_Private\wRMS\wRMS_Miscellaneous Forms\Main Application\frmUpdate.vb 38 Error
BC30506 Handles clause requires a WithEvents variable defined in the containing type or one of its base types. wRMS D:_Private\wRMS\wRMS_Miscellaneous Forms\Main Application\frmUpdate.vb 42 Blockquote

从“构建”菜单中单击“清理”不会更改任何内容。

我在表单上创建并使用了许多自定义控件(按钮、复选框、列表等)。 Eazfuscator 在编译期间混淆了那些控件的名称,这使得表单在设计器中不再可见(这一直是一个症状);但是现在,如果我看到上述错误,一旦它被混淆,IDE 将不允许我重建解决方案,而且我什至无法重建它 NON-obfuscated。我只是卡住了。

不幸的是,当这种情况发生时,项目将无法再次编译,我基本上必须从备份中恢复项目并丢失我的工作。

这是什么原因造成的?我能做什么?我能否以某种方式清除解决方案,以便 IDE 直接从源代码重建而根本不查看混淆的输出?

最佳答案

问题出在 VS2015 上,你不能在 Debug模式下混淆程序集,IDE 会“崩溃”,因为用户控件的对象名称已被更改为乱码。它会删除控件,并且出于某种原因甚至会删除它周围的标准 WinForms 控件。

解决方案是只允许您的混淆器在 Release模式下进行混淆,方法是编辑您的构建后事件以说出如下内容(取决于您的混淆器):

if /I "$(ConfigurationName)" == "Release" Eazfuscator.NET.exe "$(TargetPath)" --msbuild-project-path "$(ProjectPath)" --msbuild-project-configuration "$(ConfigurationName)" --msbuild-project-platform "$(PlatformName)" --msbuild-solution-path "$(SolutionPath)" -n --newline-flush -v 5.1

不幸的是,如果您偶然发现了这个问题,您的源代码就会被破坏,您必须从备份中恢复。

实现一些 DevOps 并不断进行备份;由于永久指定语句:

if /I "$(ConfigurationName)" == "Release" 

似乎已经永久解决了我的问题。

Microsoft 以及 EAZfuscator 已收到通知

https://connect.microsoft.com/VisualStudio/feedback/details/1833336/obfuscated-assembly-in-debug-mode-causes-ide-to-delete-winforms-controls

2017 年更新:两年后回到这里,值得注意的是您需要注意您的 IDE。如果您最后一次在 Release 模式下构建(显然程序集被混淆了),请不要打开任何 FORM,直到您首先在 Debug 模式下重建。 Debug模式会将程序集状态重置为未混淆,您可以毫无问题地查看表单。

如果您不小心在混淆 Release模式下打开了一个表单并且它在显示时中断了,只需关闭 IDE 内的每个窗口,让 IDE 保持打开状态,然后在 Debug模式下重建。现在您可以毫无问题地继续了。

关于vb.net - 为什么 Visual Studio 2015 失败并显示错误代码 BC30506,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32733520/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com