Questions tagged [mono.cecil]

Mono.Cecil is a library to generate and inspect programs and libraries in the ECMA CIL form.

Mono.Cecil is a cross platform library, working equally well on .net and Mono, used to analyze, modify and write .net assemblies.

It is used in a variety of open source projects and commercial products.

Links

390 questions
23
votes
1 answer

How do I replace embedded resources in a .NET assembly programmatically?

I am trying to replace a Resource of an exe (.NET, C#) file using C# code. I have found this article and made this code (using Mono.Cecil 0.6): AssemblyDefinition asdDefinition = AssemblyFactory.GetAssembly("C:\\File.exe"); EmbeddedResource erTemp =…
eranj
  • 367
  • 1
  • 3
  • 8
23
votes
2 answers

Mono.Cecil TypeReference to Type?

Is there anyways to go from a TypeReference in Mono.Cecil to a Type?
Will
  • 10,013
  • 9
  • 45
  • 77
20
votes
2 answers

CCI vs. Mono.Cecil -- advantages and disadvantages

I have seen articles discussing these two similar frameworks, but most of them are two years old or so. I assume both projects are much more mature now than they were two years ago, and the situation is a more complex one. So given the current…
cloudraven
  • 2,484
  • 1
  • 24
  • 49
16
votes
3 answers

Adding custom attributes using mono.cecil?

I can't figure how to add custom attribute to a method using Mono.Cecil The attributes that I would want to add is like this : .custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = ( 01 00 00 00 ) Does anyone know…
method
  • 1,369
  • 3
  • 16
  • 29
16
votes
3 answers

Mono Cecil vs. PostSharp Core vs. Microsoft CCI for implementing AOP framework

Which is the better in terms of capabilities, easy of use, documentation, samples, community/support, VS integration, known implementations, long-term viability, and build speed to implement a custom AOP framework? I'll start with what I know (I…
user65199
13
votes
1 answer

Not able to find AssemblyFactory class using Mono.Cecil

I am using the Mono.Cecil DLL file and writing this code: AssemblyDefinition sourceAssembly = AssemblyFactory.GetAssembly(assemblyPath); My project is not getting compiled, because it is not able to find the class "AssemblyFactory". As if this…
samar
  • 5,021
  • 9
  • 47
  • 71
13
votes
2 answers

How to use Mono.Cecil to create HelloWorld.exe

How do you use Mono.Cecil to create a simple program from scratch? All the examples and tutorials I've been able to find so far, assume you are working with an existing assembly, reading or making small changes.
rwallace
  • 31,405
  • 40
  • 123
  • 242
13
votes
1 answer

Static Constructor Creation [Mono.Cecil]

I've been having some issues with static constructors with my project. I need to add a static constructor to the type "" in order to call my resource decryption method. Below in the gif you will see the issue I run into. I will also include the code…
user2699298
  • 1,446
  • 3
  • 17
  • 33
12
votes
1 answer

How to get attribute value for an assembly in Cecil

Is there a way to get str1 in code ? [MyAttribute("str1")] class X {} The instance of Mono.Cecil.CustomAttribute.Fields is empty.
Kumar
  • 10,997
  • 13
  • 84
  • 134
12
votes
2 answers

How to create an override method using Mono.Cecil?

I'm using Mono.Cecil to generate an assembly that contains a derived class that overrides a specific method in an imported base class. The override method is an 'implicit' override. The problem is that I cannot figure out how to designate it as an…
John Holliday
  • 1,268
  • 1
  • 11
  • 19
12
votes
1 answer

Difference between IKVM.Reflection.Emit and Mono.Cecil

IKVM.Reflection.Emit has "the ability to read and emit .NET 1.1, .NET 2.0 and .NET 4.0 assemblies (while running on, for example, .NET 2.0).". Does Mono.Cecil have the same? Are they interchangable for this use case? Are they both supported…
Vlad
  • 3,001
  • 1
  • 22
  • 52
12
votes
1 answer

Mono-Cecil: How can I get a ModuleDefinition for mscorlib?

I'm trying to write IL that calls methods in mscorlib, but I can't figure out how to get a ModuleDefinition to mscorlib to actually reference the types & methods, and documentation & google are lacking.
thecoop
  • 45,220
  • 19
  • 132
  • 189
12
votes
1 answer

Add a try-catch with Mono Cecil

I am using Mono Cecil to inject Code in another Method. I want to add a Try-Catch block around my code. So i wrote a HelloWorld.exe with a try catch block and decompiled it. It looks like this in Reflector for the Try-Catch: .try L_0001 to L_0036…
cyptus
  • 3,346
  • 3
  • 31
  • 52
10
votes
1 answer

How to get source/line number for IL instruction using Mono.Cecil

I'm using Mono.Cecil to write a simple utility that looks for type/method usage within .NET assemblies (ex. calling ToString on enums). I am able to get find the method, but it would be cool to display the source/line information to the user. Is…
Filip Frącz
  • 5,881
  • 11
  • 45
  • 67
10
votes
1 answer

Does Mono.Cecil take care of branches etc location?

Well this question may seem odd but it's simple - my point is if i have a "goto" (brtrue etc) in the decompiled code like example br IL_0003 call ***** IL_0003: ret and I add a command after that **** call will the br at the top point to ret like…
n00b
  • 5,642
  • 2
  • 30
  • 48
1
2 3
25 26