1

当我混淆这个表单并“调试”它时

public partial class Form1 : Form
{
  public void Form1()
  {
    InitializeComponents();
  }

  protected override void OnShown(EventArgs e)
  {
      base.OnShown(e);
      Console.WriteLine("Name: "+this.Name);
      Console.WriteLine("FullName: "+this.GetType().FullName);
  }
}

输出是这样的:

姓名:Form1全名
:#Yab.#Zab


问题
为什么会FullName混淆?
Form1是公开的,所以我希望 SmartAssembly 忽略它。

额外的信息
Form1public partial,designer.cs

我的 SmartAssembly 设置是这样的:

    <ApplicationName />
    <Destination DestinationFileName=".\bin.obfuscated\MyProject.Form1.exe" />
    <Assemblies>
        <Assembly AssemblyName="MyProject.Form1, Culture=neutral, PublicKeyToken=omitted">
            <Merging>
                <ResourcesCompression Compress="0" />
                <MemberRefsProxy />
                <Pruning />
                <Obfuscation Obfuscate="1">
                  <Exclusions />
                </Obfuscation>
                <ControlFlow Obfuscate="1" />
            </Merging>
        </Assembly>
    </Assemblies>
    <Options>
      <Obfuscation FieldsNameMangling="2" NameMangling="1" />
      <ExceptionReporting />
      <FeatureUsageReporting Template="res:SmartUsageWithUIConsentFirstRun1033.dll" />
      <StrongNameSigning KeyFileName="PathToKeyFile" Sign="1" />
      <OtherProtections />
      <StringsEncoding />
      <OtherOptimizations />
      <Debugging />
    </Options>
4

1 回答 1

2

首先,SmartAssembly 在应用程序项目中不会忽略公共类(它将在库项目中被忽略)。

其次,表单的Name 属性是在运行时设置的属性。在您的情况下,它可能会在您的代码中的某处(可能在设计器中)初始化为“Form1”。

该值可以随时更改,例如:

public Form1()
{
    InitializeComponent();
    this.Name = "foo";
}

所以 SmartAssembly 不能混淆这个值,这将是错误的并且会改变你的代码的行为。

当 SmartAssembly 混淆您的代码时,它只会更改类型、字段和方法的名称。当您尝试获取类型的名称时,获取类型的混淆名称是合乎逻辑的。

于 2014-06-12T13:33:22.637 回答