简体   繁体   English

如何将.net dll反编译为项目C#[CompilerGenerated]

[英]How decompile .net dll to project c# [CompilerGenerated]

when decompile dll using dotpeek I am getting this code 当使用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;

...

}

how fix this and build project ?? 如何解决这个问题并建立项目?

First you need to understand what the role is of this compiler generated class is, what it is, and how it relates to the code it was generated for. 首先,您需要了解此编译器生成的类的作用是什么,它是什么以及它与为其生成的代码之间的关系。

In the case of these call site objects, they are typically used for code that utilizes dynamic values. 对于这些呼叫站点对象,它们通常用于利用dynamic值的代码。 Without going into full detail, this information is needed for the runtime to be able to do the magic that it does when it comes to working with dynamic . 无需详细介绍,运行时就需要此信息,以使其能够发挥与dynamic

eg, 例如,

dynamic something = ...;
// any code that involves the variable `something` will generate call site information

Generally speaking, when the runtime is required to reference a dynamic variable as if it was some specific type or object, it will create a call site object. 一般而言,当要求运行时像引用某个特定类型或对象一样引用动态变量时,它将创建一个调用站点对象。 It will do this for every subexpression that involves the dynamic variable. 它将为每个涉及动态变量的子表达式执行此操作。

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>>

Knowing this, find out where those fields are used and try to convert the expressions involving that field to using dynamic following these patterns. 知道这一点后,找出使用这些字段的位置,然后尝试将涉及该字段的表达式转换为使用dynamic遵循这些模式的表达式。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM