Java2C# Antonio Cisternino Part V. Outline Assembly & co. Visual Studio environment Example: using DirectX from C#

Slides:



Advertisements
Similar presentations
What is.Net Gary Devendorf. .Net Framework.Net framework works like the Domino Objects only much lower level and very complete It is part of the OS (or.
Advertisements

Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 12 Introduction to ASP.NET.
1 Copyright © 2005, Oracle. All rights reserved. Introducing the Java and Oracle Platforms.
.NET Framework Overview
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.
Building Localized Applications with Microsoft.NET Framework and Visual Studio.NET Achim Ruopp International Program Manager Microsoft Corp.
Lab Information Security Using Java (Review) Lab#0 Omaima Al-Matrafi.
.NET Framework Overview Pingping Ma Nov 16 th, 2006.
.NET Technology.
Overview of the.NET Framework. What is the.NET Framework A new computing platform designed to simplify application development A consistent object-oriented.
Presented by IBM developer Works ibm.com/developerworks/ 2006 January – April © 2006 IBM Corporation. Making the most of Creating Eclipse plug-ins.
Introducing the Common Language Runtime for.NET. The Common Language Runtime The Common Language Runtime (CLR) The Common Language Runtime (CLR) –Execution.
Assembly Where it all gets physical. Objectives Introduce concepts of assemblies Discuss elements of assemblies Show how to build assemblies Runtime aspects.
Introducing the Common Language Runtime. The Common Language Runtime The Common Language Runtime (CLR) The Common Language Runtime (CLR) –Execution engine.
Creating and Running Your First C# Program Svetlin Nakov Telerik Corporation
Tahir Nawaz Visual Programming C# Week 2. What is C#? C# (pronounced "C sharp") is an object- oriented language that is used to build applications for.
Object Oriented Software Development 1. Introduction to C# and Visual Studio.
HELIA – Bite ATK36F © Tuomo Ketomäki.NET Overview.NET Programming.
Intro to dot Net Dr. John Abraham UTPA – Fall 09 CSCI 3327.
Windows.Net Programming Series Preview. Course Schedule CourseDate Microsoft.Net Fundamentals 01/13/2014 Microsoft Windows/Web Fundamentals 01/20/2014.
Introduction to.Net and ASP.Net Course Introduction Build Your Own ASP.Net Website: Chapter 1 Microsoft ASP.Net Walkthrough: Creating a Basic Web Forms.
Lecture Roger Sutton CO530 Automation Tools 5: Class Libraries and Assemblies 1.
Lecture 8 – Platform as a Service. Introduction We have discussed the SPI model of Cloud Computing – IaaS – PaaS – SaaS.
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.
The Metadata System1. 2 Introduction Metadata is data that describes data. Traditionally, metadata has been found in language- specific files (e.g. C/C++
Architecture of.NET Framework .NET Framework ٭ Microsoft.NET (pronounced “dot net”) is a software component that runs on the Windows operating.
.NET Overview. 2 Objectives Introduce.NET –overview –languages –libraries –development and execution model Examine simple C# program.
Session 1 - Introduction and Data Access Layer
DEV343.NET Application and Library Versioning Juval Löwy
CIS NET Applications1 Chapter 2 –.NET Component- Oriented Programming Essentials.
Lecture Set 1 Part B: Understanding Visual Studio and.NET – Structure and Terminology 1/16/ :04 PM.
Understanding Code Compilation and Deployment Lesson 4.
Creating and Running Your First C# Program Svetlin Nakov Telerik Corporation
Lesley Bross, August 29, 2010 ArcGIS 10 add-in glossary.
Importing outside DLLs into.Net platform and using them By Anupama Atmakur.
Understanding the CORBA Model. What is CORBA?  The Common Object Request Broker Architecture (CORBA) allows distributed applications to interoperate.
ASSEMBLY. A SSEMBLY Assemblies are the fundamental units of applications in the.net framework An assembly can contain classes, structures, interfaces.
Introduction .NET Framework
ASSEMBLIES AND THE GAC CHAPTER 1, LESSONS 4-7 & LAB.
C# Overview and Features. Content I.History of C# II.Architecture III.How to install IV.Features V.Code Sample VI.Microsoft.NET Platform VII.Why use C#
Lecture 1 Programming in C# Introducing C# Writing a C# Program.
Component-Based Software Engineering Introduction to.NET Paul Krause.
.NET Framework Danish Sami UG Lead.NetFoundry
The Web Architecture and ASP.NET. Slide 2 Review of the Web (1) It began with HTTP and HTML, which delivers static Web pages to browsers which would render.
MSIL & CLI Kun-Yuan Shieh.
1 Module Objective & Outline Module Objective: After completing this Module, you will be able to, appreciate java as a programming language, write java.
Week 1: THE C# LANGUAGE Chapter 1: Variables and Expressions ➤ Included in Visual Studio.NET ➤ What the.NET Framework is and what it contains ➤ How.NET.
Module 1: Getting Started. Introduction to.NET and the.NET Framework Exploring Visual Studio.NET Creating a Windows Application Project Overview Use Visual.
Core Java Introduction Byju Veedu Ness Technologies httpdownload.oracle.com/javase/tutorial/getStarted/intro/definition.html.
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.
.NET Ying Chen Junwei Chen. What is Microsoft.NET. NET is a development platform Incorporated into.NET COM+ component services ASP web development framework.
Getting Started with.NET Getting Started with.NET/Lesson 1/Slide 1 of 31 Objectives In this lesson, you will learn to: *Identify the components of the.NET.
Text Introduction to.NET Framework. CONFIDENTIAL Agenda .NET Training – Purpose  What is.NET?  Why.NET?  Advantages  Architecture  Components: CLR,
Lecture Set 1 Part B: Understanding Visual Studio and.NET – Structure and Terminology 1/16/ :04 PM.
Sung-Dong Kim Dept. of Computer Engineering, Hansung University Chapter 3 Programming Tools.
ClickOnce Deployment (One-click Deployment)
Lecture 1: The .NET Architecture
Introduction to .NET framework
Outline Introduction to the Phalanger System
.Net A brief introduction to
Introduction to .NET Framework Ch2 – Deitel’s Book
CE-105 Spring 2007 Engr. Faisal ur Rehman
.NET and .NET Core 2. .NET Runtimes Pan Wuming 2017.
CS360 Windows Programming
Module 1: Getting Started
.NET Base Type (CTS Data Type) Managed Extensions for C++ Keyword
ClickOnce Deployment (One-click Deployment)
Presentation transcript:

Java2C# Antonio Cisternino Part V

Outline Assembly & co. Visual Studio environment Example: using DirectX from C#

Outline Assembly & co. Visual Studio environment Example: using DirectX from C#

Code packaging in Java Java classes are compiled into bytecode Each class C definition resides into a separate file named C.class Inner classes are stored in files whose names are formed by appending the class names separated with $ and the extension.class Jar files are ZIP files! Inside there are.class files and possibly a manifest with information about the package (i.e. the main class)

Code packaging in.NET.NET adopts a coarser grain packagin model w.r.t. Java Code is deployed in assemblies An assembly is a file whose format is based on Windows PE Inside an assembly there are one or more modules containing code Each code module may contain native code as well as CIL

Assemblies The special case for CLI files is defined within the standard: it is platform independent A CLI section of PE is formed by several tables describing one or more types: data (code) and metadata An assembly could be signed and has a version Signature and version are controlled using assemblies custom attributes

Assembly’s metadata General information: [assembly: AssemblyTitle("Direct3D Sample")] [assembly: AssemblyDescription("Example of using Direct3D 8 from C#")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("Antonio Cisternino")] [assembly: AssemblyProduct("")] [assembly: AssemblyCopyright("")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("Neutral")] Version information: [assembly: AssemblyVersion("1.0.*")] // Major.Minor.Build.Revision Assembly signing: [assembly: AssemblyDelaySign(false)] [assembly: AssemblyKeyFile("")] [assembly: AssemblyKeyName("")]

CLR and Assemblies Execution Engine relies on assemblies to find and load types Assemblies can be precompiled to improve load time (ngen tool) There is no CLASSPATH, assemblies are searched as follows:  Determines the correct assembly version by examining applicable configuration files, including the application configuration file, publisher policy file, and machine configuration file. If the configuration file is located on a remote machine, the runtime must locate and download the application configuration file first.  Checks whether the assembly name has been bound to beforeand, if so, uses the previously loaded assembly.  Checks the global assembly cache. If the assembly is found there, the runtime uses this assembly.  Probes for the assembly using the following steps: If configuration and publisher policy do not affect the original reference and if the bind request was created using the Assembly.LoadFrom method, the runtime checks for location hints. If a codebase is found in the configuration files, the runtime checks only this location. If this probe fails, the runtime determines that the binding request failed and no other probing occurs. Probes for the assembly using the heuristics described in the probing section. If the assembly is not found after probing, the runtime requests the Windows Installer to provide the assembly. This acts as an install-on-demand feature.

Assembly cache CLR relies on two caches: the global assembly cache (GAC) and the native image cache that contains pre- compiled assemblies.NET Framework ships with utilities to manage these caches (gacutil and ngen) Cache and assembly-level loading enable a wide range of JIT optimization techniques Tradeoffs are:  Disk space  Load time  Execution time

Outline Assembly & co. Visual Studio environment Example: using DirectX from C#

Visual Studio 7 Visual Studio is becoming an open development environment The.NET version can be extended with a (near to) public interface called Babel Each language has a plugin that handle with syntax checking, intellisense, etc. It supports outlining: code becomes structured and code navigation becomes easier The debugger is integrated into the environment and is multi-language

Demo

Outline Assembly & co. Visual Studio environment Example: using DirectX from C# Example: Web services

DirectX DirectX is an API that exposes direct access to peripherals from programs It is widely used to game programming due to a significant improvement of performances There are several modules to cope with 3D graphics, 2D drawing, input, sound and so on It is a C++ library accessible from VB and.NET through a COM component

Accessing DirectX from C# To access DirectX from C# the only way is to use interoperability The COM component is called DIRECT.DirectX8.0 and has a type-library Using tlbimp it is possible to get a.NET assembly that exposes all the interfaces of that component The C# application uses the output as DirectX library Unsafe code is needed to be able to call certain interface methods!

Initialization DX8 = new DirectX8Class(); D3D = DX8.Direct3DCreate(); D3DDISPLAYMODE mode = new D3DDISPLAYMODE(); D3D.GetAdapterDisplayMode((int)CONST_D3DCONST.D3DADAPTER_D EFAULT, ref mode); D3DPRESENT_PARAMETERS d3dpp = new D3DPRESENT_PARAMETERS(); d3dpp.Windowed = 1; d3dpp.SwapEffect = CONST_D3DSWAPEFFECT.D3DSWAPEFFECT_COPY_VSYNC; d3dpp.BackBufferFormat = mode.Format; D3DDevice = D3D.CreateDevice((int)CONST_D3DCONST.D3DADAPTER_DEFAULT, CONST_D3DDEVTYPE.D3DDEVTYPE_HAL, this.Handle.ToInt32(), CONST_D3DCREATEFLAGS.D3DCREATE_SOFTWARE_VERTEXPROCESSING, ref d3dpp);

Custom vertices Direct3D allows a flexible vertex format that can be controlled using bitmasks In our case: struct CUSTOM_VERTEX { public float x; public float y; public float z; public float rhw; public uint color; public CUSTOM_VERTEX(float xx, float yy, float zz, float r, uint c) { x = xx; y = yy; z = zz; rhw = r; color = c; }

Rendering of two triangles protected override void OnPaint(PaintEventArgs e) { unsafe { CUSTOM_VERTEX[] vertices = new CUSTOM_VERTEX[]{ new CUSTOM_VERTEX(10, 10, 0.5f, 1, 0xffff0000), …}; int sizeOfVertices = sizeof(CUSTOM_VERTEX) * vertices.Length; Direct3DVertexBuffer8 vb; vb = D3DDevice.CreateVertexBuffer(sizeOfVertices, 0, (int)(CONST_D3DFVFFLAGS.D3DFVF_XYZRHW | CONST_D3DFVFFLAGS.D3DFVF_DIFFUSE), CONST_D3DPOOL.D3DPOOL_DEFAULT); fixed (void* v = vertices) { int pData; byte* src = (byte*)v, dest; vb.Lock(0, sizeOfVertices, out pData, 0); dest = (byte*)pData; for (int i = 0; i < sizeOfVertices; i++) *dest++ = *src++; } D3DDevice.Clear(0, new IntPtr(0), CONST_D3DCLEARFLAGS.D3DCLEAR_TARGET, unchecked((int)0xff666699), 1.0f, 0); D3DDevice.BeginScene(); D3DDevice.SetStreamSource(0, vb, sizeof(CUSTOM_VERTEX)); D3DDevice.SetVertexShader((int)(CONST_D3DFVFFLAGS.D3DFVF_XYZRHW | CONST_D3DFVFFLAGS.D3DFVF_DIFFUSE)); D3DDevice.DrawPrimitive(CONST_D3DPRIMITIVETYPE.D3DPT_TRIANGLELIST, 0, 2); D3DDevice.EndScene(); D3DDevice.Present(new IntPtr(0), new IntPtr(0), 0, new IntPtr(0)); }}

Demo

Next Lecture Web services Framework SDK:  Compilers  Tools  …