Chapter 9 S. NandaGopalan, BIT

Slides:



Advertisements
Similar presentations
Using.NET Platform Note: Most of the material of these slides have been taken & extended from Nakov’s excellent overview for.NET framework, MSDN and wikipedia.
Advertisements

Using Eclipse. Getting Started There are three ways to create a Java project: 1:Select File > New > Project, 2 Select the arrow of the button in the upper.
Compunet Corporation Programming with Visual Studio.NET GUI Week 13 Tariq Aziz and Kevin Jones.
Visual Studio 2005 Using the DataGridView Control V. Matos Cleveland State University.
Multiple Forms & Procedures. Form Methods: –Show, Hide, Activate, Close Events: –Load, Activated, Closing, Closed.
1 An Introduction to Visual Basic Objectives Explain the history of programming languages Define the terminology used in object-oriented programming.
Chapter 2 –Visual Basic, Controls, and Events
Visual Basic 2008 Express Edition The IDE. Visual Basic 2008 Express The Start Page Recent Projects Open an existing project Create a New Project.
ACCESS CHAPTER 1. OBJECTIVES Tables Queries Forms Reports Primary and Foreign Keys Relationship.
1 Namespaces and Assemblies © University of Linz, Institute for System Software, 2004 published under the Microsoft Curriculum License.
CIS NET Applications1 Chapter 2 –.NET Component- Oriented Programming Essentials.
.NET Framework & C#.
Microsoft Visual Basic 2005: Reloaded Second Edition
Understanding Code Compilation and Deployment Lesson 4.
Importing outside DLLs into.Net platform and using them By Anupama Atmakur.
Writing Classes (Chapter 4)
Module 7: Object-Oriented Programming in Visual Basic .NET
Computer Programming and Basic Software Engineering 9 Building Graphical User Interface Working with Unmanaged Code.
ASSEMBLY. A SSEMBLY Assemblies are the fundamental units of applications in the.net framework An assembly can contain classes, structures, interfaces.
1.  A method describes the internal mechanisms that actually perform its tasks  A class is used to house (among other things) a method ◦ A class that.
1 Κατανεμημένες Διαδικτυακές Εφαρμογές Πολυμέσων Γιάννης Πετράκης.
Clearly Visual Basic: Programming with Visual Basic 2008 Chapter 4 I Need a Tour Guide.
Chapter 3 – Fundamentals of Programming in VB.NET VB.NET Controls VB.NET Events Numbers Strings Input and Output.
Lecture 8 Visual Basic (2).
.NET Framework Danish Sami UG Lead.NetFoundry
VB Procedures. Procedures. Sub procedure: Private/Public Sub SubName(Arguments) … End Sub Private: Can only be accessed by procedures in the same form.
Windows Forms. Architecture Wrapper around WIN32API Part of the.NET Framework Code can be in C# or VB Toolbox has forms elements (buttons, etc.) Dragging.
Microsoft Visual Basic 2008 CHAPTER TWELVE Cell Phone Applications and Web Services.
Introduction to Web Services. Examples Using a Web Service Creating a new Web Service.
Module 3: Using Microsoft.NET- Based Languages. Overview Overview of the.NET-Based Languages Comparison of the.NET-Based Languages.
Chapter 4 Introduction to Classes, Objects, Methods and strings
VB Classes ISYS 512/812. Object-Oriented Concepts Abstraction: –To create a model of an object, for the purpose of determining the characteristics (properties)
COPYRIGHT 2010: Dr. David Scanlan, CSUS OBJECTIVES: How to write classes How to create an object from a class using the "New" keyword. How to communicate.
Hands-on Introduction to Visual Basic.NET Programming Right from the Start with Visual Basic.NET 1/e 6.
Created by Alia Al-Abdulkarim 2008 Visual Basic Vs. Java.
What is GAC Repository containing all the assemblies of CLR Machine wide Assemblies shared by several applications Where CLR is installed C:\Windows\Microsoft.NET\assembly\GAC_MSIL.
Using ADO.Net to Build a Login System Dr. Ron Eaglin.
ADO.NET Objects Data Adapters Dr. Ron Eaglin. Agenda Builds on Information in Part I Should have working knowledge of creating a database connection Continuation.
July 22, 2001Introduction to.NET1 Introduction to.NET Framework Gholamali Semsarzadeh July 2001.
Introduction to VB programming Dr. John P. Abraham UTPA Chapters 2 & 3.
Assemblies. 2 Objectives Introduce assemblies –concept –creation –naming Discuss deployment –main.exe –dependent assemblies.
METADATA IN.NET Presented By Sukumar Manduva. INTRODUCTION  What is Metadata ? Metadata is a binary information which contains the complete description.
ClickOnce Deployment (One-click Deployment)
Electronic Commerce Java (1)
Building C# Applications
.NET MCQs MULTIPLE CHOICE QUESTION
Chapter 2: The Visual Studio .NET Development Environment
Programming in visual basic .net Visual Basic Building Blocks
INF230 Basics in C# Programming
Advanced Object-Oriented Programming Features
Apply Procedures to Develop Message, Input, and Dialog Boxes
USING ECLIPSE TO CREATE HELLO WORLD
Introduction to VB programming
.NET and .NET Core 2. .NET Runtimes Pan Wuming 2017.
CS360 Windows Programming
Introduction to C# AKEEL AHMED.
Programming in C# CHAPTER 1
للمزيد زورونا على موقعنا الإلكتروني:
1.الدوال Function 2.الاجراءاتSub Procedure 3.وحده نمطيه Add Module
Social Media And Global Computing Using DLLs with MVC
Classes, Objects, Methods and Strings
Tonga Institute of Higher Education
Accessing Databases with ADO.NET, Handling Exceptions, and Printing
How to organize and document your classes
Database Handling Class and Service
CIS 338: Images on Forms Dr. Ralph D. Westfall May, 2009.
The Role of Command Line Compiler (csc.exe)
Overview of the IDE Visual Studio .NET is Microsoft’s Integrated Development Environment (IDE) for creating, running and debugging programs (also.
ClickOnce Deployment (One-click Deployment)
GUI Programming in Visual Studio .NET
Presentation transcript:

Chapter 9 S. NandaGopalan, BIT .NET Assemblies Chapter 9 S. NandaGopalan, BIT

Chapter 9 S. NandaGopalan, BIT Objectives Overview of .NET Assemblies Building Single File Assembly Cross Language Inheritance Building Multifile Assembly Private Assembly Shared Assembly (GAC) Building Shared Assemblies Strong Names (sn) Chapter 9 S. NandaGopalan, BIT

Overview of .NET Assemblies An Assembly is nothing but a versioned, self describing binary (*.dll or *.exe) Contains classes, interfaces, structures. Also some optional resources like images, string tables, etc.) Assemblies help in code reuse The format of .Net binaries are completely new Chapter 9 S. NandaGopalan, BIT

Elements of .NET Binaries Windows file header CLR header CIL code Metadata Assembly Manifest Chapter 9 S. NandaGopalan, BIT

Single File Assembly Format Foo.dll Manifest Metadata CIL Code Resources Chapter 9 S. NandaGopalan, BIT

Format of Multifile Assembly Bar.netmodule Foo.dll Metadata Manifest Metadata CIL Code CIL Code Qazz.netmodule Metadata CIL Code CLogo.bmp Chapter 9 S. NandaGopalan, BIT

Building Single File Assembly Step 1: Open the new Project Window. Select Visual C# Projects -> Class Library. Name this project as BankLibrary Chapter 9 S. NandaGopalan, BIT

Chapter 9 S. NandaGopalan, BIT BankLibrary… Step 2: Type the code for BankLibrary with the following details: Account – Class Deposit() – to deposit the amount Withdraw() – to withdraw the amount Balance – property balance – member data Refer to 'BankLibrary' Folder for the code Chapter 9 S. NandaGopalan, BIT

Chapter 9 S. NandaGopalan, BIT Subclass : SBAccount Step 3: Select Project -> Add Class.. and name the class as SBAccount. Step 4: Select Project -> Add Reference -> System.Windows.Forms.dll. Press Select button. Step 4: Add the following line in the program: using System.Windows.Forms; Chapter 9 S. NandaGopalan, BIT

Chapter 9 S. NandaGopalan, BIT C# Client Application How to make use of our BankLibrary type for any client? We shall show first for a C# client. Follow the steps as: Step 1: Open a C# Console Application. Name it as BankClient Step 2: Press Project->Add Reference. Press Browse button and click on the appropriate BankLibrary.dll file of BankLibrary project. Step 3: Add the following line in the code: using BankLibrary; Step 4: Type the code as given in the file BankClient.cs. Chapter 9 S. NandaGopalan, BIT

Chapter 9 S. NandaGopalan, BIT Code and Output static void Main(string[] args) { SBAccount sb = new SBAccount(); sb.Deposit(1000); sb.showBalance(); } Chapter 9 S. NandaGopalan, BIT

Chapter 9 S. NandaGopalan, BIT VB .NET Client Add a new VB .NET Project called VBClient (windows application) Chapter 9 S. NandaGopalan, BIT

Chapter 9 S. NandaGopalan, BIT VB .NET Client Step 2: Add the following line: Imports BankLibrary Step 3: Create a Button and name it as Balance Step 4: Type the code for this button (double click) Chapter 9 S. NandaGopalan, BIT

Chapter 9 S. NandaGopalan, BIT Code Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim sb As New SBAccount sb.Deposit(400) sb.showBalance() sb.Withdraw(100) End Sub Chapter 9 S. NandaGopalan, BIT

Cross Language Inheritance Can we create a subclass of Account in VB .NET? ……… Yes! But how? Step 1: In the same project of VBClient, add a class called CAAccount Press Project->Add Class and select class icon with name of the class as CAAccount Step 2: Add the following lines in the code: Public Class CAAccount Inherits BankLibrary.Account Public Overloads Sub showBalance() MessageBox.Show("It is a Current Account") End Sub End Class Step 3: Create a new Button on the same form called 'Current Account'. Double this button to add the following code Dim ca As New CAAccount ca.showBalance() Chapter 9 S. NandaGopalan, BIT

Chapter 9 S. NandaGopalan, BIT Multifile Assembly Left as an Exercise……….. Chapter 9 S. NandaGopalan, BIT

Chapter 9 S. NandaGopalan, BIT Shared Assemblies Shared assemblies can be used by several clients on a single machine For example, System.Windows.Forms.dll is deployed as a shared assembly. This is why any application can set a reference to this dll. private assemblies must be kept in the same directory as that of the application and this need not be true for shared assemblies All shared assembly files are kept in C:\WINDOWS\assembly These assemblies can use machine-wide applications: Global Assembly Cache (GAC) Chapter 9 S. NandaGopalan, BIT

Chapter 9 S. NandaGopalan, BIT Steps to add in GAC Step 1: An Assembly should be assigned with a strong name (sn) Strong Name is used to uniquely identify the publisher of a given .NET binary Strong Name string name of the assembly version number public key culture identity Chapter 9 S. NandaGopalan, BIT

Building Shared Assembly Step 2: Now create a new C# ClassLibrary named as SharedAssembly Step 3: Type the code as shown in SharedAssembly folder and compile Step 4: Create the strong key Chapter 9 S. NandaGopalan, BIT

Class Library for Std Class using System; using System.Windows.Forms; public class Std { private int USN; public Std() MessageBox.Show("using Version 1.0.0.0"); } public void Dummy() MessageBox.Show("Calling Dummy method"); public int usn get { return USN; } set { USN = value; } Chapter 9 S. NandaGopalan, BIT

Building Shared Assembly… Step 5: We must inform this snk to C# compiler where the *.snk file is located to record the public key in the assembly manifest Step 6: Open the AssemblyInfo.cs and modify the file as shown below: update this line [assembly: AssemblyKeyFile("")] Specify the directory path of *.snk file [assembly: AssemblyKeyFile(@"C:\Documents and Settings\SNG\myKey.snk>")] Step 7: Change the following line [assembly: AssemblyVersion("1.0.*")] to [assembly: AssemblyVersion("1.0.0.0")] Chapter 9 S. NandaGopalan, BIT

Building Shared Assembly… Step 8: Type the following code after opening a new C# Console Application project named as 'TestSharedAssembly' using SharedAssembly; class TestSharedAssembly { static void Main(string[] args) Std s = new Std(); s.Dummy(); } Chapter 9 S. NandaGopalan, BIT

Chapter 9 S. NandaGopalan, BIT Versioning the dll Step 1: Update your class by adding new functionality or modify the existing class Step -2: Relocate your old dll file with version 1.0.0.0 Step 3: Change the AssemblyInfo.cs file to reflect the new version: 2.0.0.0 Step 4: Compile your *.cs file. Now you will see two binaries with the same name in GAC (however, they are different versions) – try this………! Chapter 9 S. NandaGopalan, BIT

Chapter 9 S. NandaGopalan, BIT End of Chapter 9 Chapter 9 S. NandaGopalan, BIT