OE-NIK HP Advanced Programming Using and creating DLL files.

Slides:



Advertisements
Similar presentations
Creating a Dialog-Based Comet Windows Program Brian Levantine.
Advertisements

Part IV: Memory Management
Linkage Editors Difference between a linkage editor and a linking loader: Linking loader performs all linking and relocation operations, including automatic.
Linking & Loading CS-502 Operating Systems
Loaders and Linkers CS 230 이준원. 2 Overview assembler –generates an object code in a predefined format »COFF (common object file format) »ELF (executable.
The Functions and Purposes of Translators Code Generation (Intermediate Code, Optimisation, Final Code), Linkers & Loaders.
CS 31003: Compilers ANIRUDDHA GUPTA 11CS10004 G2 CLASS DATE : 24/07/2013.
Programming Our First Java Program Yingcai Xiao. What to Do Set up for Java Programming Write our first Java Program with IDE Write our first Java Program.
Names and Scopes CS 351. Program Binding We should be familiar with this notion. A variable is bound to a method or current block e.g in C++: namespace.
1/50 Project Management. 2/50 StumbleUpon 3/50 Overview Customize? Why, what, how?.NET Framework overview & fundamentals Class libraries, namespaces,
Data Structure and Algorithm 1 Yingcai Xiao. You Me The Course (
Programming A Historic Perspective on Code Reuse Yingcai Xiao.
Introducing the Common Language Runtime for.NET. The Common Language Runtime The Common Language Runtime (CLR) The Common Language Runtime (CLR) –Execution.
CMP 131 Introduction to Computer Programming Violetta Cavalli-Sforza Week 1, Lab.
A. Frank - P. Weisberg Operating Systems Real Memory Management.
Introducing the Common Language Runtime. The Common Language Runtime The Common Language Runtime (CLR) The Common Language Runtime (CLR) –Execution engine.
Code-Reuse A Historic Perspective Yingcai Xiao. Want to know? Why we have to write programs to run a computer? Why an error in a program is called a bug?
2. Developing in.NET and C#. 2 Microsoft Objectives “Microsoft.NET development is based on an underlying framework of tools and classes. These tools and.
1 An Introduction to Visual Basic Objectives Explain the history of programming languages Define the terminology used in object-oriented programming.
COP4020 Programming Languages
Chapter 91 Memory Management Chapter 9   Review of process from source to executable (linking, loading, addressing)   General discussion of memory.
Intro to dot Net Dr. John Abraham UTPA – Fall 09 CSCI 3327.
A Free sample background from © 2001 By Default!Slide 1.NET Overview BY: Pinkesh Desai.
Lecture Roger Sutton CO530 Automation Tools 5: Class Libraries and Assemblies 1.
Language Systems Chapter FourModern Programming Languages 1.
M1G Introduction to Programming 2 4. Enhancing a class:Room.
Introduction to .Net Framework
1 Namespaces and Assemblies © University of Linz, Institute for System Software, 2004 published under the Microsoft Curriculum License.
1 8/29/05CS360 Windows Programming Professor Shereen Khoja.
1 Program Execution in the 21 st Century Modern Software Development in.NET and C# A webcast series for C++, Java, and VB6 developers – Part 1 of 15: [
© 2008 Dr. Paul Walcott – The University of the West Indies: Cave Hill CampusDr. Paul Walcott COMP6325 Advanced Web Technologies Dr. Paul Walcott The University.
The Metadata System1. 2 Introduction Metadata is data that describes data. Traditionally, metadata has been found in language- specific files (e.g. C/C++
Module 1: Introduction to C# Module 2: Variables and Data Types
Session 1 - Introduction and Data Access Layer
CIS NET Applications1 Chapter 2 –.NET Component- Oriented Programming Essentials.
.NET Framework & C#.
Microsoft Visual Basic 2005: Reloaded Second Edition
CSC 494/594 C# and ASP.NET Programming. C# 2012 C# Object-oriented language with syntax that is similar to Java.
Importing outside DLLs into.Net platform and using them By Anupama Atmakur.
A genda for Today What is memory management Source code to execution Address binding Logical and physical address spaces Dynamic loading, dynamic linking,
All 300/400 Level CS Major Courses Tutoring Location: SEC 3433 Sign up or walk-in Introduction2-1.
ASSEMBLIES AND THE GAC CHAPTER 1, LESSONS 4-7 & LAB.
.NET Framework Danish Sami UG Lead.NetFoundry
Linking and Loading Linker collects procedures and links them together object modules into one executable program. Why isn't everything written as just.
Java ACO101: Introduction to Computer Science. The History of Java Started out as a research project at Sun Microsystems in 1991 Code named “Green” Based.
Languages and IDE (Integrated Development Environment)
© Janice Regan, CMPT 300, May CMPT 300 Introduction to Operating Systems Memory: Relocation.
LANGUAGE SYSTEMS Chapter Four Modern Programming Languages 1.
Lecture 4: J# Execution Model. 2 MicrosoftIntroducing CS using.NETJ# in Visual Studio.NET 4-2 Objectives “J# programs execute like any other.NET program.
1. The .NET Architecture 1. The .NET Architecture 2003
Object Oriented Software Development 4. C# data types, objects and references.
Module 4: Deployment and Versioning. Overview Introduction to Application Deployment Application Deployment Scenarios Related Topics and Tools.
Program Libraries 1. What is a program library? A library is a collection of implementations of behavior, written in terms of a language, that has a well-defined.
Introduction to the Microsoft.NET Framework Chris Wastchak Student Ambassador to Microsoft.
Computer System Structures
Linking & Loading.
CS-3013 Operating Systems C-term 2008
2.1. Compilers and Interpreters
Introduction to C# AKEEL AHMED.
COEN 252 Computer Forensics
Chapter 8: Memory management
Outline Module 1 and 2 dealt with processes, scheduling and synchronization Next two modules will deal with memory and storage Processes require data to.
Computer Organization and Design Assembly & Compilation
Linking & Loading CS-502 Operating Systems
.Net Framework Details Imran Rashid CTO at ManiWeber Technologies.
Web programming and advanced development techniques
Linking & Loading CS-502 Operating Systems
Introduction to AppDomains
IS 135 Business Programming
Plug-In Architecture Pattern
Presentation transcript:

OE-NIK HP Advanced Programming Using and creating DLL files

V1.0 Dynamic Link Library / Shared Object Program module that can store program code and resources that can be accessed from other programs Separately compiled, it is only loaded/attached to the program during run-time ( = dynamic) Only loaded to the memory once, several programs can use the same memory instance (= shared, partly true in.NET) Today most of the OS and userspace programs are all use such files (although it is possible to use static linking, it is not good practice) In Windows OS, we must distinguish native and managed DLLs: –Native: Contains procedural bytecode that can be directly interpreted by the OS/CPU (a bunch of methods that use only simple types, even direct HW access) –Managed: Contains one (or more).NET CLR classes (CLR? see later) 2 OE-NIK HP

V1.0 Classic compile process Object File: An intermediate executable format, generated by the compiler from the source code Contains: the compiled code and the relocation data that is used by the linker to generate the executable External libraries are merged into the EXE/ELF file in case of static linking, and left as separate files in case of dynamic linking 3 OE-NIK HP Source (.cpp,.pas,.c,.cs,.*) PREPROCESS, COMPILE OBJECT FILE (.o,.obj) EXTERNAL LIBRARIES (.o,.obj,.so,.dll) LINKING EXECUTABLE FILE (.exe)

V1.0 Static linking Every method/resource is in the same module/program The location of these is already known by the compiler Every method call is pre-defined, because every method is inside the memory region of the same process The same method can be loaded by multiple programs  waste of memory, waste of resources Classic (non-overlay) DOS programs (e.g.: Turbo Pascal) 4 OE-NIK HP SomeFunct1 SomeFunct2 SomeFunct3 Constant2 Constant1 Constant3 Program

V1.0 Dynamic linking Some methods/resources are outside the memory allocated to the process The exact location of those are not known to the compiler The reference to those methods are dynamic, determined during run-time (not known during compile-time, the DLL will be loaded by the OS on demand) The same method can be used by multiple processes  shared (~ Shared Object) Most of the modern programs work this way 5 OE-NIK HP Program Program DLL SomeFunct2 SomeFunct3

V1.0.NET JIT JIT = Just-In-Time Per method, the speed loss is small due to OOP NGEN.EXE can be used, not necessarily makes faster Similar: Java Hotspot VM 6 OE-NIK HP

V1.0 Native vs. managed DLL Native DLL –Loaded from the current directory or from the %PATH% –Slow load time –%PATH% = WINDOWS, SYSTEM, SYSTEM32 directories  DLL HELL Managed DLL ( .NET DLL,.NET DLL assembly) –EVERY method/class that we used so far was a DLL call –A project’s „References” section stores the managed DLL files accessible by the project, this is editable –In the documentation you can find which class/namespace is stored in which DLL file –The managed DLLs are registered into a common storage (GAC), solving the problem of versioning and dependencies –VERY fast load time, almost as if no DLL were used 7 OE-NIK HP

V1.0 Accessing a DLL in the.NET framework Managed DLL –Add reference to the DLL file: Project/Add reference –After this, the namespaces/classes/methods of the DLL can be accessed the usual way Platform Invoke (P/Invoke: call native methods from managed environment)  DllImport attribute – using System.Runtime.InteropServices; — [DllImport("winmm.dll", SetLastError = true)] static extern bool PlaySound(string pszSound, UIntPtr hmod, uint fdwSound); — string fname PlaySound(fname, UIntPtr.Zero, 1); –WINAPI signatures, imports: 8 OE-NIK HP

V1.0 Creating a managed DLL 1 solution, 2 projects: DLL creator project + DLL user project The DLL creator project: Class Library We have to add a reference to the DLL file (or to the project itself) into the DLL using project The DLL file will be copied next to the executable file After adding the reference, the DLL namespaces and classes can be accessed the usual way 9 OE-NIK HP

V1.0 Exercise Create an applictaion, where the main program uses DLL modules to handle the different players User  controlled by the user RandomEnemy  random movements FollowerEnemy  follows the user Solve the problem using DLLs added as a reference, and also with dynamically loaded DLL files Common classes can be downloaded from the website 10 OE-NIK HP