Wrap IL into an assembly written on disk in C# / .NET Core?
Asked Answered
S

1

6

I am creating a .NET method based on raw IL. I would like to wrap the stand-alone newly created method into a .NET assembly and write this assembly to disk as a foo.dll file in order to then feed this assembly to PEVerify or ILVerify. Indeed, those tools are invaluable when it comes to debugging large bespoke IL sequences.

Does anyone knows how to do this with .NET Core?

Slim answered 4/2, 2019 at 11:6 Comment(8)
Use ilasm.Acrogen
PEVerify is tied to the full framework. Look like ILVerify might be the tool you're looking for: "ILVerify is a cross-platform, open-source tool currently being developed as part of Microsoft’s CoreRT repository. The goal of ILVerify is to alleviate PEVerify’s limitations..."Mixie
@Acrogen "ilproj" is also useful - let's you work from the IDEAnalyst
@Mixie Thanks a lot for the ILVerify tip! Just updated the question accordingly.Slim
You can also use Mono Cecil and some C# code, github.com/jbevain/cecilJardine
@JoannesVermorel What exactly do you need to know, how to create method from IL raw, or how to wrap it in a new assembly, or how to verify it?Deland
I am seeking a way to move a method - any method - into a isolated assembly on disk (assuming the method is self-contained).Slim
What's incredible is that the documentation for AssemblyBuilder in .net5 talks a ton about saving and even has an example calling Save but the method isn't actually there. Microsoft's documentation quality has gone down the toilet in the last 10 years...Diadelphous
S
12

It appears that this problem has been pending for almost 4 years. In the end, we rolled out our own open source alternative to AssemblyBuilder.Save for .NET Core.

Slim answered 3/3, 2019 at 12:4 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.