很多时候,打开别人的源码,由于 vs 版本的不一致,或多或少会发生设计时窗体打不开,出现各种各样的报错。
解决的方法,如下:
- 一、控件或基类中的常用替换
ComponentResourceManager manager 替换为 ComponentResourceManager resources
manager.GetObject 替换为 resources.GetObject
BorderStyle = BorderStyle. 替换为 BorderStyle =
System.Windows.Forms.BorderStyle.
base.ImeMode = ImeMode.KatakanaHalf; 替换为 base.ImeMode =
System.Windows.Forms.ImeMode.KatakanaHalf;
base.AutoScaleMode = AutoScaleMode.Font; 替换为 base.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
base.FormBorderStyle = FormBorderStyle.None; 替换为 base.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
base.StartPosition = FormStartPosition. 替换为 base.StartPosition =
System.Windows.Forms.FormStartPosition.
- 二、恢复资源文件
- 打开 Visual Studio 命令提示
- resgen 具体路径原始资源.resources 具体路径修复资源.resx)