1-
We use C #, VB. NET language will eventually be compiled into an assembly or IL. Therefore, code written with vb.net can be modified in C # and later used in COBOL. Therefore, it is very necessary to understand IL.
Once you are familiar with IL, there is no barrier to understanding. NET technology because all of the. NET languages are compiled to IL. Il is a neutral language. Il was first invented, followed by C #, VB. NET and other languages.
We'll show il in a short, incisive program. We also assume that the reader is at least familiar with a. NET language.
A.il
.method void vijay()
{
}
Then we wrote a very short Il program with IL--it's obviously not working, and named it a.il. So how can we compile it into an executable program? You don't have to worry about it, Microsoft provides a ilasm program whose only task is to create an executable file from an Il file.
Before allowing this command, make sure that your variable path is set to the Bin subdirectory in the framework. If not, please enter the following command:
Set path=c:\progra~1\microsoft.net\frameworksdk\bin;%path%
Now, we use the following command:
C:\il>ilasm/nologo/quiet a.il
Doing so will generate the following error:
Source file is ANSI
Error:no entry point declared for executable
Failure * * * *
In the future, we will not display the first and last lines of output generated by ILAsm. We will also remove the blank line between the blank lines.
In IL, we are allowed to use a period. As the beginning of a line, this is an instruction that requires the compiler to perform a function, such as creating a function or class, and so on. Any statement beginning with a period is an actual Russian compiler instruction.
. method represents the creation of a function (or methods) named Vijay, and this function returns void, that is, it does not return any values. Because of the lack of a better naming law, the function name Vijay seems very casual.
The assembler obviously does not understand this program, thus displaying the message "No entry point". This error message is generated because the Il file can include countless functions, and the assembler cannot distinguish which will be executed first.
In IL, the first function to be executed is called the entry point (entrypoint) function. In C #, this function is main. The syntax for a function is after the name is a pair of parentheses (). The start and end of the function code are represented by curly braces {}.
A.il
.method void vijay()
{
.entrypoint
}
C:\il>ilasm/nologo/quiet a.il
Source file is ANSI
Creating PE File
Emitting members:
Global methods:1;
Writing PE file
Operation completed successfully