当我混淆这种形式,并"调试"它

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);
  }
}

输出是这样的:

姓名:表格1
全名:#雅布。#扎布


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

额外资料
Form1public partial 设计师也是。政务司司长

我的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>
有帮助吗?

解决方案

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

其次, 名称属性 您的表单是在运行时设置的属性。在你的情况下,它可能会在你的代码中的某个地方初始化为"Form1",也许在设计器中。

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

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

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

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

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top