开发者

Get MSIL from Assembly?

Is it possible to usefully extract MSIL from an Assembly object without loading the type information?

I have a simple application that takes a string and attempts to dynamically create a method for making very fast calculations, but I want to avoid loading assembly/type information by using the CodeCompileUnit to compile a C# code string, extract the MSIL from the开发者_开发问答 compiled assembly, and emitting the MSIL into a DynamicMethod. If this is possible.


Have a look at Mono.Cecil which helps you to read/modify/create assembly without loading them.


The only way to get MSIL is to call MethodBase.GetMethodBody Method. But it requires loading of type first.


Use System.Reflection.Emit directly. For dynamic methods you don't even need a type.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜