[英]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;
...
}
如何解決這個問題並建立項目?
首先,您需要了解此編譯器生成的類的作用是什么,它是什么以及它與為其生成的代碼之間的關系。
對於這些呼叫站點對象,它們通常用於利用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
遵循這些模式的表達式。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.