Click here to Skip to main content
15,890,557 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I read topic from google and I understand this:

    Windows loader loads the exe or dll of .net app.
    Then windows loader creates clr for that process.
    Then it locates entry point to application and call it.
    But before that class loader service of clr comes and loads the class containing Main method.
    And then jit compilation takes place.
    The clr provoids services like gc,exception handling,class loading etc to our app.

My questions are:

Now when we run .net app clr locates entry point and starts execution . But when it encounters

Class1 ob = new Class1();  

that time how our process calls the service of CLR called as class loader? MSIL code equivalent to is newobj internally calls to clr's class loader service?
Posted

The process works like this:

1. particular language code gets compiled to MSIL assembly/assemblies.

2. An assembly resembles the windows PE file in a way that the first instruction in the assembly always loads the CLR which takes over in terms of compiling the rest of the content of the corresponding assembly.

Now comes your question wherein you asked how does CLR loads the classes being referenced in the assembly. For this to understand you need to know little bit more on what is dot net assembly and what content it holds. An assembly always have two things:

1. Assembly manifest
2. MSIL code

Apart from many other things the assembly manifest part contains all the references of any other assebmlies (that might contain the MSIL code of classes that are referenced in this MSIL) or any other resources i.e., documentataion, dlls referenced any other information. So the CLR looks up this part and compiles/executes the corresponding assembly accordingly.

I'd recommend that you drill down on what, why and how of dot net assemblies.

Regards
Pawan
 
Share this answer
 
Comments
fdiu 5-Nov-12 2:26am    
Ok but my que. is diffèrent.when main function follows this stmt like "class1 ob=new class1" how this stmt calls the "class loading service of clr"
Rai Pawan 5-Nov-12 2:38am    
I would not be able to give you a detailed working process of .Net loader. For some general details on dotnet loader read this:
http://www.informit.com/articles/article.aspx?p=30601&seqNum=5

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900