如何将 .net dll 反编译为项目 c# [CompilerGenerated]
How decompile .net dll to project c# [CompilerGenerated]
当使用 dotpeek 反编译 dll 时,我得到了这段代码
[CompilerGenerated]
private static class <Importuj>o__SiteContainer0
{
public static CallSite<Func<CallSite, object, Worksheet>> <>p__Site1;
public static CallSite<Func<CallSite, object, bool>> <>p__Site2;
public static CallSite<Func<CallSite, object, object, object>> <>p__Site3;
public static CallSite<Func<CallSite, object, Range>> <>p__Site4;
public static CallSite<Func<CallSite, object, bool>> <>p__Site5;
public static CallSite<ImportExcel.<Importuj>o__SiteContainer0.<>q__SiteDelegate6> <>p__Site7;
public static CallSite<Func<CallSite, object, object>> <>p__Site8;
public static CallSite<Func<CallSite, object, Range>> <>p__Site9;
...
}
如何解决这个问题并构建项目??
首先,您需要了解此编译器生成的 class 的作用是什么,它是什么,以及它与为其生成的代码有何关系。
对于这些调用站点对象,它们通常用于使用 dynamic
值的代码。无需详细说明,运行时需要此信息才能发挥它在处理 dynamic
.
时的魔力
例如
dynamic something = ...;
// any code that involves the variable `something` will generate call site information
一般来说,当运行时需要像引用某个特定类型或对象一样引用动态变量时,它会创建一个调用站点对象。它将为涉及动态变量的每个子表达式执行此操作。
int someInt = something.SomeInt; // some property that returns int
// CallSite<Func<CallSite, Object, Int32>>
something.SomeMethod(); // some object that has some method `SomeMethod()`
// CallSite<Func<CallSite, Object, Object>>
SomeValue x = something[123]; // some indexer that takes an int,
// that returns something that might be SomeValue
// CallSite<Func<CallSite, Object, Int32, Object>>
// and CallSite<Func<CallSite, Object, SomeValue>>
了解这一点,找出这些字段的使用位置,并尝试按照这些模式将涉及该字段的表达式转换为使用 dynamic
。
当使用 dotpeek 反编译 dll 时,我得到了这段代码
[CompilerGenerated]
private static class <Importuj>o__SiteContainer0
{
public static CallSite<Func<CallSite, object, Worksheet>> <>p__Site1;
public static CallSite<Func<CallSite, object, bool>> <>p__Site2;
public static CallSite<Func<CallSite, object, object, object>> <>p__Site3;
public static CallSite<Func<CallSite, object, Range>> <>p__Site4;
public static CallSite<Func<CallSite, object, bool>> <>p__Site5;
public static CallSite<ImportExcel.<Importuj>o__SiteContainer0.<>q__SiteDelegate6> <>p__Site7;
public static CallSite<Func<CallSite, object, object>> <>p__Site8;
public static CallSite<Func<CallSite, object, Range>> <>p__Site9;
...
}
如何解决这个问题并构建项目??
首先,您需要了解此编译器生成的 class 的作用是什么,它是什么,以及它与为其生成的代码有何关系。
对于这些调用站点对象,它们通常用于使用 dynamic
值的代码。无需详细说明,运行时需要此信息才能发挥它在处理 dynamic
.
例如
dynamic something = ...;
// any code that involves the variable `something` will generate call site information
一般来说,当运行时需要像引用某个特定类型或对象一样引用动态变量时,它会创建一个调用站点对象。它将为涉及动态变量的每个子表达式执行此操作。
int someInt = something.SomeInt; // some property that returns int
// CallSite<Func<CallSite, Object, Int32>>
something.SomeMethod(); // some object that has some method `SomeMethod()`
// CallSite<Func<CallSite, Object, Object>>
SomeValue x = something[123]; // some indexer that takes an int,
// that returns something that might be SomeValue
// CallSite<Func<CallSite, Object, Int32, Object>>
// and CallSite<Func<CallSite, Object, SomeValue>>
了解这一点,找出这些字段的使用位置,并尝试按照这些模式将涉及该字段的表达式转换为使用 dynamic
。