Questions tagged [ilasm]

The MSIL Assembler generates a portable executable (PE) file from Microsoft intermediate language (MSIL). You can run the resulting executable, which contains MSIL and the required metadata, to determine whether the MSIL performs as expected.

76 questions
4
votes
1 answer

Ilasm.exe injects mscorlib dependency in .NET Standard 2.0 dll

I'm building a .NET Core 2.0 library from IL. I earlier did exactly the same for .NET Core 1.0/1.1 with no issues. However, the same thing does not work for .NET Core 2.0 dll. After running…
Alex
  • 2,469
  • 3
  • 28
  • 61
4
votes
1 answer

.NET Framework 4 ILASM targeting framework 2

Question: I need to create, using ILASM.EXE, framework 2.0 assemblies. So far, I have seen that fw 2 ilasm: creates 2.0 assembies. FW 4 ilasm, on the other hand: creates 4.0 assemblies. So far I am cool. Now I need to know: is there a way (perhaps…
Daniel Dolz
  • 2,403
  • 1
  • 18
  • 23
4
votes
1 answer

Defining custom attributes in CIL

What is the syntax for defining an array literal in CIL for the purposes of decorating a member with a custom attribute? I am writing some .NET code in CIL (using ilasm.exe to compile it) and I need to decorate a method with a custom attribute. The…
Jono
  • 1,964
  • 4
  • 18
  • 35
4
votes
1 answer

How is the Visual Studio compiler compiling Security Attributes to CIL?

I have the following attribute SecurityPermission(SecurityAction.Assert) on a method in my class. I compile it (debug build) and view the output in ildasm.exe by viewing the raw heaps and looking at the blob heap containing the PermissionSet blob. …
Micah Zoltu
  • 6,764
  • 5
  • 44
  • 72
4
votes
2 answers

Calling ILAsm global function from C# code

Suppose I have an ILAsm library with the following code: .assembly extern mscorlib{} .assembly TestMe{} .module TestMe.dll .method public static void PrintMe() cil managed { ldstr "I'm alive!" call void…
user2341923
  • 4,537
  • 6
  • 30
  • 44
3
votes
1 answer

Is there a way to run ILASM from F# code?

I am making a compiler from (a small subset of) Java to CIL (MSIL) in F# and I was thinking about writing some unit tests for the actual compilation part. Is there a way I could run ilasm on the generated IL code and the run the .exe file from a…
AndreiXwe
  • 723
  • 4
  • 19
3
votes
1 answer

Modifying IL code causing InvalidProgramException at runtime

Im trying to remove the subscription to the Tick event in IL Code so that it wont ever fire. Here is the IL Code: IL_0e19: ldftn instance void App.Framework.MainForm::mTimer_Tick(object, class [mscorlib]System.EventArgs) IL_0e1f: newobj …
CathalMF
  • 9,705
  • 6
  • 70
  • 106
3
votes
2 answers

c# hide class members when exporting DLL

Can I only make some methods visible to the end user when I'm publishing a DLL to third party applications? My code is built upon 7-8 different projects which call each other, they have different namespaces like "Company.ProjectName" which I think…
Taha Paksu
  • 15,371
  • 2
  • 44
  • 78
3
votes
1 answer

Problem with ilasm

I have a quite big program in .net 3.5 SP1 which is compiling just fine. However when I want to obfuscate it with Obfuscator Pro (evaluation for now), Obfuscator stops with the following error: [Build Output] This application has requested the…
Marc
  • 9,012
  • 13
  • 57
  • 72
3
votes
1 answer

Common Language Runtime detected an invalid program - ILGenerator

Basically i am trying to deserialize data that is inside an byte array into objects. I am trying to use GetString method of UTF8 Encoding in order to read a string. Here is part of my code: var mm = new DynamicMethod("get_value", typeof(object) …
Faisal
  • 73
  • 7
3
votes
1 answer

tail. prefix in ILAsm – any example of use?

ECMA-335, III.2.4 specifies tail. prefix that can be used in recursive functions. However, I could not find its usage neither in C# nor in F# code. Are there any example of using in?
user2341923
  • 4,537
  • 6
  • 30
  • 44
3
votes
3 answers

Failure using ilasm, but no reason given

I am trying to use ILASM and the process seems to abort with the following message: ***** FAILURE ***** How can I find out why it has failed? Can I turn on verbose messages or is there a log file I can look at?
CJ7
  • 22,579
  • 65
  • 193
  • 321
3
votes
1 answer

How do I replace an ILAsm throw with a rethrow with Mono.Cecil?

I have a C# dll with a member similar to the following: public void DoStuff(int i) { try { something.InnerDoStuff(i); } catch (Exception ex) { throw ex; } } I figured out how to get the throw opcode: Add-Type -Path…
Justin Dearing
  • 14,270
  • 22
  • 88
  • 161
3
votes
2 answers

Why does my IL generated Assembly, ilasm.exe called by C#, need UAC?

I'm trying to compile an IL Code to an Assembly. The ilasm.exe should get called by my C# Application. I'm invoking the ilasm.exe through an ProcessStartInfo Instance. The generation of the PE works fine and my Assembly is working. My problem is…
2
votes
0 answers

Modify the version information of a built .NET assembly

Is there a better way to modify the version information of a .NET assembly of the one I am currently using. My current approach is the following. I do disassemble the assembly with ildasm: ildasm /nobar Riolo.WebUI.dll /out=Riolo.WebUI.il This…
aledeniz
  • 431
  • 3
  • 13