Does the .NET framework always call the API?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Peter Olcott

    #1

    Does the .NET framework always call the API?

    I want to double check my understanding about how the .NET framework works. From
    what I understand every call to the .NET framework is ultimately translated into
    one of more API calls, is this correct?


  • Joanna Carter [TeamB]

    #2
    Re: Does the .NET framework always call the API?

    "Peter Olcott" <olcott@att.net > a écrit dans le message de news:
    DlEAf.68924$QW2 .46682@dukeread 08...

    |I want to double check my understanding about how the .NET framework works.
    From
    | what I understand every call to the .NET framework is ultimately
    translated into
    | one of more API calls, is this correct?

    The .NET framework is a massive library mainly written in managed code.
    where the framework needs to , it calls existing APIs but there is a lot of
    brand new code that doesn't need the old APIs.

    Joanna

    --
    Joanna Carter [TeamB]
    Consultant Software Engineer


    Comment

    • Lebesgue

      #3
      Re: Does the .NET framework always call the API?

      Try to download Reflector http://www.aisto.com/roeder/dotnet/ or have a
      look at Rotor source code to see what the ".NET framework calls" exactly
      do - most of them are definitely not API calls.

      "Peter Olcott" <olcott@att.net > wrote in message
      news:DlEAf.6892 4$QW2.46682@duk eread08...[color=blue]
      >I want to double check my understanding about how the .NET framework works.
      >From what I understand every call to the .NET framework is ultimately
      >translated into one of more API calls, is this correct?
      >[/color]


      Comment

      • John Timney \( MVP \)

        #4
        Re: Does the .NET framework always call the API?

        I would expect it to only call any API's when its handling calls within the
        Microsoft namespace, as this touches more on microsoft operating system
        functionality - whereby the remaining namespaces are cross platform and
        would be very unlikely to drop into API's.

        --
        Regards

        John Timney
        Microsoft MVP

        "Peter Olcott" <olcott@att.net > wrote in message
        news:DlEAf.6892 4$QW2.46682@duk eread08...[color=blue]
        >I want to double check my understanding about how the .NET framework works.
        >From what I understand every call to the .NET framework is ultimately
        >translated into one of more API calls, is this correct?
        >[/color]


        Comment

        • Mike Labosh

          #5
          Re: Does the .NET framework always call the API?

          Whooo. Interesting. OK, folks, the OP just sent me on a mission to find
          out. The very first thing that comes to mind is to spy on the system and
          look at who is invoking whom. I cannot seem to find it on my system, but
          there used to be a cool utility called APIMON.EXE that would list (log?) api
          calls as they are called. It had a cartoon-like Frankenstein icon. Anyone
          remember it?

          It is the first step to the OP question, but now that I can't find the
          thing, I would be grateful for any hints on how to *legitmately* acquire it.

          --
          Peace & happy computing,

          Mike Labosh, MCSD MCT
          "Escriba coda ergo sum." -- vbSensei
          "Peter Olcott" <olcott@att.net > wrote in message
          news:DlEAf.6892 4$QW2.46682@duk eread08...[color=blue]
          > I want to double check my understanding about how the .NET framework[/color]
          works. From[color=blue]
          > what I understand every call to the .NET framework is ultimately[/color]
          translated into[color=blue]
          > one of more API calls, is this correct?
          >
          >[/color]


          Comment

          • Sharon

            #6
            Re: Does the .NET framework always call the API?

            You can download the API monitor version 1.5 from:
            API Monitor is a software that monitors and displays API calls made by applications and services. Its a powerful tool for seeing how Windows and other applications work or tracking down problems that you have in your own applications


            -----
            Enjoy
            Sharon

            Comment

            • Peter Olcott

              #7
              Re: Does the .NET framework always call the API?

              I am referring to those cases that result in API functionality, for example GDI
              output to the display screen. Did MS write a whole new way to output things to
              the screen, or merely wrap these calls in the .NET framework?

              "Joanna Carter [TeamB]" <joanna@not.for .spam> wrote in message
              news:%23phZ8NzH GHA.2896@TK2MSF TNGP09.phx.gbl. ..[color=blue]
              > "Peter Olcott" <olcott@att.net > a écrit dans le message de news:
              > DlEAf.68924$QW2 .46682@dukeread 08...
              >
              > |I want to double check my understanding about how the .NET framework works.
              > From
              > | what I understand every call to the .NET framework is ultimately
              > translated into
              > | one of more API calls, is this correct?
              >
              > The .NET framework is a massive library mainly written in managed code.
              > where the framework needs to , it calls existing APIs but there is a lot of
              > brand new code that doesn't need the old APIs.
              >
              > Joanna
              >
              > --
              > Joanna Carter [TeamB]
              > Consultant Software Engineer
              >
              >[/color]


              Comment

              • Daniel O'Connell [C# MVP]

                #8
                Re: Does the .NET framework always call the API?


                "John Timney ( MVP )" <timneyj@despam med.com> wrote in message
                news:ehjAkx1HGH A.3448@TK2MSFTN GP10.phx.gbl...[color=blue]
                >I would expect it to only call any API's when its handling calls within the
                >Microsoft namespace, as this touches more on microsoft operating system
                >functionalit y - whereby the remaining namespaces are cross platform and
                >would be very unlikely to drop into API's.
                >[/color]
                That isn't totally complete by any means. While the remaining namespaces
                are designed tobe platform independent, many still rely on platform
                dependent mechanisms. Take the System.IO namespace for example. On Windows
                it is likely using CreateFile and its ilk and on Linux perhaps the posix IO
                system and on a third system whatever it uses. Same goes for
                System.Windows. Forms(although that doesn't port very well), some of
                System.Security (WindowsIdentit y definatly uses windows APIs, Identity
                classes for other systems would use that API as well, System.Threadin g(which
                may or may not use system threads depending on implementation and how it is
                hosted), and many other namespaces.

                That is why Mono had to rewrite the class library instead of just copy it.
                Large portions do rely on the underlying system, otherwise the framework
                would have to replace everything from device drivers up. That doesn't mean
                that every call, the string editing functions, large pieces of ASP.NET, much
                of if not all of System.Xml for example, result in API calls, but many
                things do..

                [color=blue]
                > --
                > Regards
                >
                > John Timney
                > Microsoft MVP
                >
                > "Peter Olcott" <olcott@att.net > wrote in message
                > news:DlEAf.6892 4$QW2.46682@duk eread08...[color=green]
                >>I want to double check my understanding about how the .NET framework
                >>works. From what I understand every call to the .NET framework is
                >>ultimately translated into one of more API calls, is this correct?
                >>[/color]
                >
                >[/color]


                Comment

                • Willy Denoyette [MVP]

                  #9
                  Re: Does the .NET framework always call the API?

                  The framework classes and the run-time (the CLR) both wrap the Win32 API's
                  to call into OS and related services (like GDI+).

                  The framework (mostly written in C#) uses PInvoke to perform these API
                  calls, while the CLR (unmanaged C++) can directly call any API it
                  likes/needs. The framework and the CLR also call into system services
                  through COM interop, the CLR debugging, profiling and unmanaged hosting
                  interfaces are all COM interfaces. Some classes in the framework are thin
                  wrappers around COM services like ADSI, WMI, COM+., others use a mixture of
                  PInvoke and COM interop and a majority don't need to call into external
                  native code at all, but they might call into the CLR through the
                  internalcall interface. Some classes in v2 are written in managed C++ and
                  use C++ interop to call into unmanaged code.



                  Willy.


                  "Peter Olcott" <olcott@att.net > wrote in message
                  news:xsNAf.6893 7$QW2.29587@duk eread08...
                  |I am referring to those cases that result in API functionality, for example
                  GDI
                  | output to the display screen. Did MS write a whole new way to output
                  things to
                  | the screen, or merely wrap these calls in the .NET framework?
                  |
                  | "Joanna Carter [TeamB]" <joanna@not.for .spam> wrote in message
                  | news:%23phZ8NzH GHA.2896@TK2MSF TNGP09.phx.gbl. ..
                  | > "Peter Olcott" <olcott@att.net > a écrit dans le message de news:
                  | > DlEAf.68924$QW2 .46682@dukeread 08...
                  | >
                  | > |I want to double check my understanding about how the .NET framework
                  works.
                  | > From
                  | > | what I understand every call to the .NET framework is ultimately
                  | > translated into
                  | > | one of more API calls, is this correct?
                  | >
                  | > The .NET framework is a massive library mainly written in managed code.
                  | > where the framework needs to , it calls existing APIs but there is a lot
                  of
                  | > brand new code that doesn't need the old APIs.
                  | >
                  | > Joanna
                  | >
                  | > --
                  | > Joanna Carter [TeamB]
                  | > Consultant Software Engineer
                  | >
                  | >
                  |
                  |


                  Comment

                  • Lloyd Dupont

                    #10
                    Re: Does the .NET framework always call the API?

                    "Peter Olcott" <olcott@att.net > wrote in message
                    news:DlEAf.6892 4$QW2.46682@duk eread08...[color=blue]
                    >I want to double check my understanding about how the .NET framework works.
                    >From what I understand every call to the .NET framework is ultimately
                    >translated into one of more API calls, is this correct?[/color]
                    hmmm... your question doesn't makes much sense.
                    I don't really know what you mean so here are some various element of
                    response:


                    API: "Applicatio n Program Interface", basically that the set of all classes
                    / method / library available as a single unit from a third party, in your
                    case you refer the .NET API as being all the classes by default in the
                    framework.

                    an API call: when you call 1 method of the framework. When you do 1 call you
                    do 1 call (and not 0 or 2).

                    Could an API call itself?
                    as much as you refer your own method in your own code.


                    Maybe you mean: The .NET API ultimately calls into the Win32 API ?

                    well not always, depending on the situation.
                    For exemple string.Format() simple manipulate and hardly need to call any
                    win32 code
                    On the other hand Form.Show() certainly call ShowWindow() and other win32
                    functions.


                    Comment

                    • Cor Ligthert [MVP]

                      #11
                      Re: Does the .NET framework always call the API?

                      Peter,

                      In my opinion is it not important what Net uses.

                      Net provides a system that let you call the underlying OS parts. If this is
                      Win32, WinFX or Linux should not be important.

                      If that are called API's so what, for you that should not be important.

                      Just my thought,

                      Cor


                      Comment

                      • Richard Grimes

                        #12
                        Re: Does the .NET framework always call the API?

                        John Timney ( MVP ) wrote:[color=blue]
                        > I would expect it to only call any API's when its handling calls
                        > within the Microsoft namespace, as this touches more on microsoft
                        > operating system functionality - whereby the remaining namespaces are
                        > cross platform and would be very unlikely to drop into API's.[/color]

                        I don't think you've thought this through John.

                        For example, the classes in System.Enterpri seServices are almost all
                        direct wrappers around the COM+ APIs. Then there are classes in
                        System.Net.Sock ets where many classes are wrappers around Winsock 2.0,
                        and then there's classes in System.Threadin g that are wrappers around
                        Win32 threads and synchronization objects, do I need to go on?

                        Yes there are classes that are pure IL and don't make any calls to Win32
                        or Windows COM objects, but many classes do. I have done an analysis of
                        various versions of .NET by checking metadata to see which methods are
                        COM, pinvoke, or embedded native code, and which are internalcall. I
                        have also 'walked' through all IL in every IL method to see the method
                        calls it makes and then analyse the type of method called. The results
                        are shown here:



                        For .NET v2.0 I find that there are

                        Methods in the framework:

                        IL Methods 92.8%
                        COM methods 4.2%
                        pinvokeimpl methods 2.5%
                        internalcall methods 0.40%
                        native methods 0.04%

                        Thus the implementation of almost 7% of methods is not in IL.

                        Method calls within the assembly:

                        IL Methods 56.3%
                        COM methods 0.18%
                        pinvokeimpl methods 0.98%
                        internalcall methods 0.80%
                        native methods 0.02%

                        Method calls outside the assembly:

                        IL Methods 38.3%
                        COM methods 0.03%
                        pinvokeimpl methods 0.01%
                        internalcall methods 2.3%
                        native methods 0%

                        This is better, just over 1% of calls is to non-IL methods.

                        Of course, my analysis does not take in to account how often methods are
                        called. AFAIK the method calls implemented through pinvoke may be the
                        most called methods <g>

                        Richard
                        --
                        Fusion Tutorial: http://www.grimes.demon.co.uk/workshops/fusionWS.htm
                        Security Tutorial:



                        Comment

                        • Cor Ligthert [MVP]

                          #13
                          Re: Does the .NET framework always call the API?

                          > John Timney ( MVP ) wrote:
                          [color=blue][color=green]
                          >> I would expect it to only call any API's when its handling calls
                          >> within the Microsoft namespace, as this touches more on microsoft
                          >> operating system functionality - whereby the remaining namespaces are
                          >> cross platform and would be very unlikely to drop into API's.[/color]
                          >
                          > I don't think you've thought this through John.
                          >[/color]
                          I assume that what you give is for Linux. Most of us know what it is for
                          current Windows Win32 systems. In my opinion is John however talking about
                          other systems. Of course is Net mainly a layer upon the OS. It would be very
                          crazy when it would gives other results way called by Net than direct by
                          other use of that.

                          Dit you think about that as John obiously did.

                          Cor


                          Comment

                          • Jon Skeet [C# MVP]

                            #14
                            Re: Does the .NET framework always call the API?

                            Cor Ligthert [MVP] wrote:[color=blue][color=green]
                            > > John Timney ( MVP ) wrote:[/color]
                            >[color=green][color=darkred]
                            > >> I would expect it to only call any API's when its handling calls
                            > >> within the Microsoft namespace, as this touches more on microsoft
                            > >> operating system functionality - whereby the remaining namespaces are
                            > >> cross platform and would be very unlikely to drop into API's.[/color]
                            > >
                            > > I don't think you've thought this through John.
                            > >[/color]
                            > I assume that what you give is for Linux.[/color]

                            Why would you assume that? It seems unlikely given that the title of
                            the page Richard is ".NET as a Win32 Wrapper".
                            [color=blue]
                            > Most of us know what it is for current Windows Win32 systems.
                            > In my opinion is John however talking about other systems.[/color]

                            Again, I'm not sure where you get that impression from.

                            Jon

                            Comment

                            • Cor Ligthert [MVP]

                              #15
                              Re: Does the .NET framework always call the API?

                              Jon,
                              [color=blue][color=green][color=darkred]
                              >> > I don't think you've thought this through John.
                              >> >[/color]
                              >> I assume that what you give is for Linux.[/color]
                              >
                              > Why would you assume that? It seems unlikely given that the title of
                              > the page Richard is ".NET as a Win32 Wrapper".
                              >[color=green]
                              >> Most of us know what it is for current Windows Win32 systems.
                              >> In my opinion is John however talking about other systems.[/color]
                              >
                              > Again, I'm not sure where you get that impression from.
                              >[/color]

                              I am not blind and I can read.

                              It was the way it was written to John to give an answer in the same way as
                              it was in my idea given to John, while in my idea Johns answer was very
                              correct.

                              Cor


                              Comment

                              Working...