On Tue, May 4, 2010 at 3:59 PM, Alix <[email protected]> wrote:
> I simply want to use the support for parsing and replacing
> instructions, since all System.Reflection offers is a byte array. I
> can parse it myself, of course, but Cecil is more convenient.

But why would you want to parse and replace instructions as you're in
control of what you emit in the MethodBuilder? Just emit what you want
in a first place.

> In a semi-unrelated question: how do you create a type with Cecil? I'd
> like to take a pre-existing type and create a type that extends it
> (i.e., a subclass). I don't want to replace the pre-existing type or
> the assembly, nor write the assembly to disk. Is it possible?

Cecil can read and write assemblies. And in between, it lets you
modify them. So if you want to create a new type, you have to do it in
a new assembly. And you have to load this assembly, either by loading
using Assembly.Load(byte[]) or LoadFile/From.

You can have a look at
http://github.com/jbevain/cecil/blob/master/Test/Mono.Cecil.Tests/ImportCecilTests.cs
for an example.

-- 
Jb Evain  <[email protected]>

-- 
--
mono-cecil

Reply via email to