.Net 反编译注意事项

用FileDisassembler反编译Windows Application程序得到源码后,需要进行以下修改:

  1. 由于FileDisassembler会给每个命名空间生成一个目录,保存这个空间的源代码,而对于资源resx文件就是直接加在项目目录下,所有要把它放回源码目录下.例如
    对于项目文件夹里面的TryAssemb.Form1.resx,首先改为Form1.resx然后移动到TryAssemb目录里面。
  2. 对所有System.Windows.Forms.命名空间里面的控件需要全命名空间的
    声明,例如里面上图的base.AutoScaleMode
    =AutoScaleMode.Font;就要改成base.AutoScaleMode =System.Windows.Forms.AutoScaleMode.Font;而TextBox textBox1;也要改成private System.Windows.Forms.TextBox
    textBox1;这样VS2008就能识别到这个控件是要绘制在Form上面的。
  3. 需要把以下代码 ComponentResourceManager manager = new
    ComponentResourceManager(typeof(ClassName)); 替换为
    System.ComponentModel.ComponentResourceManager resources = new
    System.ComponentModel.ComponentResourceManager(typeof(ClassName));
    窗体设计器才能正常识别。
  4. 将所有窗体(.cs)从工程中排除,再添加(这样可以省去将.resx文件映射到.csproj的过程)。不进行此操作,在运行时回报资源无法加载的错误。

经过以上四步的修改,源代码编译运行正常。

你可能感兴趣的:(.Net)