Questions tagged [il]

CIL (Common Intermediate Language) is a low-level language used by Microsoft .NET Framework and Mono.

477 questions
0
votes
2 answers

Generating type at runtime

I need to create type with properties at runtime. Type must be look like this: public class RunTimeType : BaseType { private string _field1; public string Property1 { get { return _field1; } set { if (_field1 != value) …
Timur
  • 3
  • 1
0
votes
3 answers

EmitCall raises "operation could destabilize the runtime" in Silverlight

I'm n00b in IL language. In my task i have to create dynamic types inherited from System.ServiceModel.DomainServices.Client.Entity. When i am adding additional code to set method of property, i receive "operation could destabilize the runtime". Help…
INs
  • 2,909
  • 2
  • 20
  • 26
0
votes
2 answers

Ensure that method return value is not discarded for library

My library has some methods whose return value should never be discarded. Leaking them is a very popular mistake even for me, the author. So I want the compiler to alert programmer when it does so. Such value may be either stored or used as an…
Vlad
  • 3,001
  • 1
  • 22
  • 52
0
votes
0 answers

How return struct object in MSIL?

I want to set a struct field value and return the struct instance. This code working in ClassType, but error on StructType. [Create Setter] public static DynamicMemberSetter CreateFieldSetter(FieldInfo fieldInfo, Type declaringType = null) …
Treenew
  • 1
  • 1
0
votes
1 answer

Can PEVerify tell me the severity of each error?

I'm modifying an assembly using Mono.Cecil, and I want to check it for validity (whether the result will run at all). I'm trying to use PEVerify, but I'm having a problem. It was designed for ensuring code is verifiable, so it just says ERROR…
GregRos
  • 8,667
  • 3
  • 37
  • 63
0
votes
0 answers

How to implement shallowcopy with IL (C#)?

I want to implement a shallow copy with C# IL instead of reflection directly. • ShallowCopy version with reflection directly: public T ShallowCopy(T instanceToShallowCopy) where T : class { Type type =…
Jason Cai
  • 1
  • 1
  • 1
  • 2
0
votes
1 answer

Test if a given object reference is valid

How can I reliably test (in IL or with some methods provided by the .NET) whether a given native int is a valid object reference (O)? The pointer may have been retrieved from some debugger, and it might not be valid (or collected after it was…
IS4
  • 11,945
  • 2
  • 47
  • 86
0
votes
1 answer

Why does the behavior of overloaded member functions differ from the behavior of non-member functions

I notice that parameters passed in to global functions always use "call", but overloaded member function calls always use "callvirt". Why does it always call the overloaded function pertaining to the base class and not the derived class when that…
jrh
  • 405
  • 2
  • 10
  • 29
0
votes
1 answer

IL .Net: How to provide step over, step through debugger support for GOSUB

I've implemented a .Net version of a legacy Basic language using IL assembler. It's working just fine. However, there's an issue of how to provide a better debugging experience for the implementation of GOSUB statement in Visual Studio IDE. The…
BSalita
  • 8,420
  • 10
  • 51
  • 68
0
votes
2 answers

Dump a process memory to file / recreate process from dump file

Just curious, maybe someone knows a way: Is it possible, while having an opened process (app domain), dump its entire memory space to a file, send it by wire to a LAN workstation and recreate the process as it was on the first…
itvist
  • 33
  • 1
  • 3
0
votes
3 answers

How to detect source code changes in async method body

I'm trying to detect during runtime if the source code of a method of a class has been changed. Basically I retrieve the method body (IL), hash it with md5 and store it in the database. Next time I check the method, I can compare the hashes. public…
Robin van der Knaap
  • 4,060
  • 2
  • 33
  • 48
0
votes
2 answers

Compile Time: How can I check if a datatype (and or value) is being used within a method

At compile time, how can I check if a data type (and or value) is being used within a method. I'm attempting to build a living architecture that supports plugins. I want the compiler to throw an error if an event is not being raised within the…
Scott Nimrod
  • 11,206
  • 11
  • 54
  • 118
0
votes
2 answers

How can I retrieve programmatically all the available IL instructions of the .NET CLR?

It is possible to get programmatically the list of all the IL instructions that a .NET compiler can produce?
0
votes
1 answer

Problems with generation of dynamic code

This code gif an exception: Invocation exception, please help, I don't know what happen, I think is some thing with the Add because he work when I push onto the stack intergers, and when i push lvalue It's didn't work, thanks static void…
cary
  • 41
  • 3
0
votes
1 answer

How can I use Mono.Cecil to call a generic method

I'm trying to import a method and its IL code like callvirt instance !!0 [UnityEngine]UnityEngine.GameObject::AddComponent() The RealMono is a MonoBehavior which I created . I have no idea to get the generic method.
KyleCTX
  • 41
  • 9