0

在已经从混淆中排除(通过命名空间)的类中(因为它必须被转移),我有一个带有这种构造函数的构造函数

public MyClass<T> (T currentObject, Func<T, int> extrator) : where T : XYZ{}

当我调用构造函数时,我会做类似的事情

new MyClass(myObject, o=>o.Id)

编译后看到反编译时添加了一个静态方法:

[CompilerGenerated]
private static int <.ctor>b__b(CurrentObjectClass e)
{
    return e.Id;
}

由于它是一种方法并且我的命名空间被排除在外,因此我期望此类不会被更改。但是在 dotfuscator 启动之后,我得到了这个:

[CompilerGenerated]
private static int <.ctor>b__5(CurrentObjectClass e)
{
//Obfuscated code
}

由于我在客户端和服务器之间使用这个类,经常发生服务器在发布(混淆)和客户端仅在调试时运行,所以我们希望这个类不被混淆以允许这个类被交换(通过.Net 远程处理)。

有没有办法防止这种行为?

4

1 回答 1

0

I found the issue:

The obfuscation has in fact nothing to do, the issue was caused because the client and the server were not generated in the same build, meaning that the compiler was generating two differents names on each compilation.

I avoided the usage of a delegate type and now it works, even with the obfuscation.

Thank you for your help.

于 2014-04-15T13:58:41.490 回答