Forums.gr Android App Forums.gr iOS App

  1. #1

    What is managed code?

    Παραθέτω το άρθρο που διαβασα και κατάλαβα τι κάνει η C#, όταν είχα κάποιες φιλοσοφικές ανησυχίες ένα φεγγάρι.

    Managed code is code that has its execution managed by the .NET Framework Common Language Runtime. It refers to a contract of cooperation between natively executing code and the runtime. This contract specifies that at any point of execution, the runtime may stop an executing CPU and retrieve information specific to the current CPU instruction address. Information that must be query-able generally pertains to runtime state, such as register or stack memory contents.
    The necessary information is encoded in an Intermediate Language (IL) and associated metadata, or symbolic information that describes all of the entry points and the constructs exposed in the IL (e.g., methods, properties) and their characteristics. The Common Language Infrastructure (CLI) Standard (which the CLR is the primary commercial implementation) describes how the information is to be encoded, and programming languages that target the runtime emit the correct encoding. All a developer has to know is that any of the languages that target the runtime produce managed code emitted as PE files that contain IL and metadata. And there are many such languages to choose from, since there are nearly 20 different languages provided by third parties – everything from COBOL to Camel – in addition to C#, J#, VB .Net, Jscript .Net, and C++ from Microsoft.
    Before the code is run, the IL is compiled into native executable code. And, since this compilation happens by the managed execution environment (or, more correctly, by a runtime-aware compiler that knows how to target the managed execution environment), the managed execution environment can make guarantees about what the code is going to do. It can insert traps and appropriate garbage collection hooks, exception handling, type safety, array bounds and index checking, and so forth. For example, such a compiler makes sure to lay out stack frames and everything just right so that the garbage collector can run in the background on a separate thread, constantly walking the active call stack, finding all the roots, chasing down all the live objects. In addition because the IL has a notion of type safety the execution engine will maintain the guarantee of type safety eliminating a whole class of programming mistakes that often lead to security holes.
    Contrast this to the unmanaged world: Unmanaged executable files are basically a binary image, x86 code, loaded into memory. The program counter gets put there and that’s the last the OS knows. There are protections in place around memory management and port I/O and so forth, but the system doesn’t actually know what the application is doing. Therefore, it can’t make any guarantees about what happens when the application runs.
    src: Brad Abrams : What is managed code?

    Και εδώ τι είναι .ΝΕΤ


  2. #2
    Μέλος Το avatar του χρήστη jss
    Εγγραφή
    Feb 2004
    Περιοχή
    ~
    Μηνύματα
    191
    Παράθεση Αρχικό μήνυμα απο grnemo Εμφάνιση μηνυμάτων
    Managed code is code that has its execution managed by the .NET Framework Common Language Runtime.
    Αγαπητέ μου φίλε αυτή η πρόταση δεν είναι λίγο περίεργη;;;; Εγώ νομίζω πως και Java κώδικας είναι managed από τη στιγμή που υπάρχει μία Virtual Machine. Θέλω να πω πως ο όρος managed code δε νομίζω πως είναι κώδικας αποκλειστικά σε .NET.

    Παρακαλώ διορθώστε με αν κάνω λάθος.

  3. #3
    Bump για να μαθαίνουν οι νέοι

    Βασικά ο jss είχε δίκιο, managed code μπορεί να θεωρηθεί οποιοσδήποτε κώδικας τρέχει σε μια VM, απλά ο όρος ήταν κυρίως πατέντα της Microsoft για κώδικα που τρέχει μέσω CLR.

  4. #4

    help

    Ο ΠΑΡΑΚΑΤΩ ΚΩΔΙΚΟΣ ΣΥΝΔΕΕΙ ΤΟΝ ΥΠΟΛΟΓΙΣΤΗ ΜΕ ΜΙΑ ΖΥΓΑΡΙΑ ΚΑΙ ΛΑΜΒΑΝΕΙ ΜΙΑ ΜΕΤΡΗΣΗ. ΜΗΠΩΣ ΜΠΟΡΕΙΤΕ ΝΑ ΜΟΥ ΠΕΙΤΕ ΠΩΣ ΘΑ ΕΙΝΑΙ Ο ΚΩΔΙΚΟΣ ΑΝ ΘΕΛΩ ΝΑ ΠΑΙΡΝΩ ΜΕΤΡΗΣΕΙΣ ΚΑΘΕ ΕΝΑ ΛΕΠΤΟ( 60 SEC) KAI NA ΑΠΟΘΗΚΕΥΟΝΤΑΙ ΜΕ ΤΟΝ ΑΡΙΘΜΟ, ΜΕ ΤΗΝ ΩΡΑ ΚΑΙ ΤΗΝ ΗΜΕΡΟΜΗΝΙΑ ΤΗΣ ΚΑΘΕ ΜΕΤΡΗΣΗΣ ΣΕ ΕΝΑ ΑΡΧΕΙΟ TXT ΣΤΟΝ ΣΚΛΗΡΟ. (Π.Χ.
    1,12.273Kg,08:55:23 πμ, 12/1/2009
    2,13.463Kg,08:56:23 πμ, 12/1/2009, κλπ)
    ΕΥΧΑΡΙΣΤΩ ΠΟΛΥ.







    Private Sub Command1_Click()
    'open connection
    If MSComm1.PortOpen = True Then MSComm1.PortOpen = False
    MSComm1.PortOpen = True
    End Sub

    Private Sub Command2_Click()
    MSComm1.Output = Trim(Text1.Text)
    'META APO EDO YPOTITHETAI OTI H ZYGARIA KANEI KATI
    End Sub

    Private Sub MSComm1_OnComm()
    'AFOY LAVEI DEDOMENA & TA EPEXERGASTEI, GYRIZEI APOTELESMA EKTELONTAS AYTH TH ROUTINA

    Select Case MSComm1.CommEvent
    ' Handle each event or error by placing
    ' code below each case statement

    ' Errors
    Case comEventBreak ' A Break was received.
    Case comEventCDTO ' CD (RLSD) Timeout.
    Case comEventCTSTO ' CTS Timeout.
    Case comEventDSRTO ' DSR Timeout.
    Case comEventFrame ' Framing Error
    Case comEventOverrun ' Data Lost.
    Case comEventRxOver ' Receive buffer overflow.
    Case comEventRxParity ' Parity Error.
    Case comEventTxFull ' Transmit buffer full.
    Case comEventDCB ' Unexpected error retrieving DCB]
    ' Events
    Case comEvCD ' Change in the CD line.
    Case comEvCTS ' Change in the CTS line.
    Case comEvDSR ' Change in the DSR line.
    Case comEvRing ' Change in the Ring Indicator.
    '************************************************* *************************************
    Case comEvReceive ' EDO LAMVANEI TO APOTELESMA
    Text2.Text = MSComm1.Input
    '************************************************* *************************************
    Case comEvSend ' There are SThreshold number of
    ' characters in the transmit
    ' buffer.
    Case comEvEOF ' An EOF charater was found in ' the input stream


    End Select
    End Sub