DEV394.NET Framework: Migrating To Managed Code Adam Nathan QA Lead Richard Lander Program Manager Microsoft Corporation.

Slides:



Advertisements
Similar presentations
Unit 1: Overview of the Microsoft.NET Platform
Advertisements

Introduction to .NET Framework
Best Practices for Interop with Visual C++ Boris Jabes Program Manager Microsoft Corporation.
DEV392: Extending SharePoint Products And Technologies Through Web Parts And ASP.NET Clint Covington, Program Manager Data And Developer Services - Office.
Introduction to.NET What is.NET?  A vision Web sites will be joined by Web services New smart devices will join the PC User interfaces will become more.
Thursday Evening 6.30VB.NET Introduction 7.30Break for food 8.00VB.NET Migration 8.45Q & A 9.00Done.
SQL Server 2005 CLR Integration ADO.NET 2.0 Mike Taulty
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.
Platforms and tools for Web Services and Mobile Applications Introduction to C# Bent Thomsen Aalborg University 3rd and 4th of June 2004.
Windows Forms in Visual Studio 2005: An Overview Saurabh Pant Program Manager Microsoft Corporation.
Introduction to VB.Net ITE-370. What is.NET? A brand of Microsoft technologies A platform for creating distributed Web applications A combination of new.
Using.NET Skills To Build Mobile Applications In Compact Framework Punit Shah Technical Lead | Microsoft |
A Free sample background from © 2001 By Default!Slide 1.NET Overview BY: Pinkesh Desai.
DEV317 Integrating Extensible Business Graphics into Enterprise Applications using Visio 2003 Mai-lan Tomsen Bukovec Program Manager.
1 Introduction to.NET Framework. 2.NETFramework Internet COM+ Orchestration Orchestration Windows.NET Enterprise ServersBuildingBlockServices Visual Studio.NET.
DEV334 Creating Application Starting Points & Sharing Best Practices with Enterprise Templates Marc Gusmano Director of Emerging Technologies The Information.
Introduction to .Net Framework
.NET Overview. 2 Objectives Introduce.NET –overview –languages –libraries –development and execution model Examine simple C# program.
11 Getting Started with C# Chapter Objectives You will be able to: 1. Say in general terms how C# differs from C. 2. Create, compile, and run a.
.NET Framework & C#.
Introduction to.NET Framework. .NET – What Is It? Software platform Language neutral In other words:.NET is not a language (Runtime and a library for.
Lesley Bross, August 29, 2010 ArcGIS 10 add-in glossary.
Microsoft Confidential Office as a Development Platform Tim Heuer
Nilotpal Bhattacharya Partner Technical Consultant| Microsoft.
ISYS 573 Special Topic – VB.Net David Chao. The History of VB Early 1960s:BASIC-Beginner’s All-Purpose Symbolic Instruction Code –Teaching –Simple syntax,
DAT305 Boost Your Data-Driven Application Development Using SQL Server Centric.NET Code Generator Pascal Belaud Microsoft France.
Managed C++. Objectives Overview to Visual C++.NET Concepts and architecture Developing with Managed Extensions for C++ Use cases Managed C++, Visual.
.NET Framework Danish Sami UG Lead.NetFoundry
Bruce Armstrong TeamSybase
DEV325 Deploying Visual Studio.NET Applications Billy Hollis Author / Consultant.
DEV331 Visual C++: Using The.NET Framework In Win32/MFC Applications Kate Gregory Gregory Consulting Limited.
Upgrading Applications to VB.NET Leveraging Your Visual Basic 6 Investments with VB 2005 & the Interop Forms Toolkit 2.0 Jonathan Aneja Program Manager.
Introduction to VB.Net. What is.NET? A brand of Microsoft technologies A platform for creating distributed Web applications A combination of new and updated.
Slide 1.NET Development for Project 2003 Samples from the Project 2003 SDK Jim Corbin Programmer Writer Office Developer Documentation Microsoft Corporation.
1 C# A brief overview by Jack Senechal and Bryan Powell.
tom perkins1 XML Web Services -.NET FRAMEWORK – Part 1 CHAPTER 1.1 – 1.3.
Name Microsoft Student Partner Overview of the Visual Studio 2005 Express Products.
Module 3: Using Microsoft.NET- Based Languages. Overview Overview of the.NET-Based Languages Comparison of the.NET-Based Languages.
Windows Role-Based Access Control Longhorn Update
VB6 Migration to.NET Sean Puffett Developer & Platform Group Microsoft Ltd
Intro to dot Net Dr. John Abraham UTPA CSCI 3327.
Key Components of.NET Framework  Common Language Runtime  CLR at Design time  CLR at Runtime  Class Library  Assemblies  Namespaces  ASP.NET  Applications.
PRIOR TO WEB SERVICES THE OTHER TECHNOLOGIES ARE:.
Introduction to VB.Net ITE-370. What is.NET? A brand of Microsoft technologies A platform for creating distributed Web applications A combination of new.
Microsoft .NET A platform that can be used for building and running windows and web applications such that the software is platform and device-independent.
PerlNET: The Camel Talks.NET Jan Dubois The Perl Conference 6 San Diego, July 26 th 2002.
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.
DEV 420 Head-Spinning C++ Managed-Native Interoperability Kate Gregory Gregory Consulting.
What’s New in Windows Forms 2.0 Stephen Turner Software Design Engineer
CIS 375—Web App Dev II ASP.NET 1 Getting Started.
Microsoft Visual Studio 2005 Tools for the Office System: Building Office Solutions Using Visual Studio 2005 Tools for Office Andrew Coates Developer Evangelist.
INTRODUCTION CHAPTER #1 Visual Basic.NET. VB.Net General features It is an object oriented language  In the past VB had objects but focus was not placed.
Steve Teixeira Group Program Manager Microsoft Corporation.
Text Introduction to.NET Framework. CONFIDENTIAL Agenda .NET Training – Purpose  What is.NET?  Why.NET?  Advantages  Architecture  Components: CLR,
Building Custom Controls with ASP.NET and the Microsoft ®.NET Framework Rames Gantanant Microsoft Regional Director, Thailand
DEV221 Windows Forms in Visual Studio 2005: An Overview Saurabh Pant Program Manager Microsoft Corporation.
Component Object Model
Component Object Model
Native / Managed Interop
.NET and .NET Core 2. .NET Runtimes Pan Wuming 2017.
Module 1: Getting Started
Introduction to C# AKEEL AHMED.
Build /23/2019 © 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks.
Module 10: Implementing Managed Code in the Database
From Development to Production: Optimizing for Continuous Delivery
From Development to Production: Optimizing for Continuous Delivery
Exploiting WinFX from Win32/MFC Applications
DOT NET ARCHITECTURE (OR) DOT NET FRAME WORK ARCHITECTURE
DAT 320 SQL Server 2000: DTS and .NET
Mark Quirk Head of Technology Developer & Platform Group
Presentation transcript:

DEV394.NET Framework: Migrating To Managed Code Adam Nathan QA Lead Richard Lander Program Manager Microsoft Corporation

Agenda Adding managed code to unmanaged code C++ Interop COM Interop Adding unmanaged code to managed code PInvoke COM Interop Hosting the CLR Q & A

Using C++ Interop Adam Nathan QA Lead Common Language Runtime

C++ Interop Extremely flexible Mixing MSIL and unmanaged code Mixing managed and existing C/C++ types Access managed types via #using Access C/C++/COM types via #include User manages “impedance mismatch” (with library support) Data types – System::String vs. BSTR Object lifetime – GC vs. ref counting

C++ Marshaling Templates Support conversions between COM Automation Types (BSTR) Standard C++ types (std::string) MFC/ATL types (CString) Extensible by adding new conversions void Func(BSTR bstrName) { String^ name = marshal_to ( bstrName ) ; String^ name = marshal_to ( bstrName ) ;}

C++ Templates for COM Interfaces ref class MyType { // Thread agnostic pointer // Thread agnostic pointer com_handle m_ipStorage; com_handle m_ipStorage; MyType(String^ name) { // Thread 1 MyType(String^ name) { // Thread 1 CComPtr ipStorage; CComPtr ipStorage; StgCreateStorageEx(…, (void**)&ipStorage); StgCreateStorageEx(…, (void**)&ipStorage); m_ipStorage = ipStorage; m_ipStorage = ipStorage; } void Stat() { // Thread 2 void Stat() { // Thread 2 m_ipStorage->Stat(…); m_ipStorage->Stat(…); }};

Related Talks For More Information DEV331 - Visual C++: Using the.NET Framework in Win32/MFC Applications DEV330 - Visual C++ Under the Covers: Targeting the CLR DEV333 - C : The Language of Choice for Native and.NET

Agenda Adding managed code to unmanaged code C++ Interop COM Interop Adding unmanaged code to managed code PInvoke COM Interop Hosting the CLR Q & A

Exposing A Managed Object Is Easy… 1. Write a managed class 2. Select “Register for COM Interop” option in Visual Studio.NET Or use TlbExp.exe to produce a type library and RegAsm.exe to register the class Or use TlbExp.exe to produce a type library and RegAsm.exe to register the class

… But Not Without Limits Not all features of managed objects are exposable to COM Static (shared) methods not exposed Parameterized constructors not exposed Overloaded methods are renamed

Windows Media Player Visualization Adam Nathan QA Lead Common Language Runtime

What Does COM Interop Do? Every managed object is a COM object Has a class factory Implements IUnknown Implements IDispatch COM callable wrapper (CCW) takes care of all this during run time

Agenda Adding managed code to unmanaged code C++ Interop COM Interop Adding unmanaged code to managed code PInvoke COM Interop Hosting the CLR Q & A

Help For “Rewriting” Code Visual Basic Upgrade Wizard

Platform Invoke (PInvoke) CLR service for using flat APIs Requires manual re-declaration of API’s method signatures No automatic wrapper creation like for COM APIs Similar to Declare statement in Visual Basic 6.0 Language-agnostic

Using PInvoke Adam Nathan QA Lead Common Language Runtime

A place to find & share PInvoke signatures & types

Managed Debugging Assistants Adam Nathan QA Lead Common Language Runtime

More MDAs In Whidbey Now cover more than just Interop Modulo Object Hashcode Jit Compilation Start Reflection Creating MemberInfo Cache DllMain Returned False Early-Bound Call On AutoDispatch Class Interface Loader Lock Report AV On COM Release Marshal Cleanup Error Invalid Constrained Execution Region Call Virtual Constrained Execution Region Call Open Generic Constrained Execution Region Call Illegal Prepare Constrained Region SafeHandle Critical Failure …

Agenda Adding managed code to unmanaged code C++ Interop COM Interop Adding unmanaged code to managed code PInvoke COM Interop Hosting the CLR Q & A

Using COM APIs From Managed Code Adam Nathan QA Lead Common Language Runtime

Choosing An Interop Technology C++ Interop Already using C++ Using IDL-Based COM components Using complex or changing flat APIs COM Interop Using TLB-Based COM components COM Interop PInvoke Using simple non-changing flat APIs

Agenda Adding managed code to unmanaged code C++ Interop COM Interop Adding unmanaged code to managed code PInvoke COM Interop Hosting the CLR Q & A

Hosting The CLR From Unmanaged Code Richard Lander Program Manager Common Language Runtime

How It Works Unmanaged host loads CLR From C++ Call CorBindToRuntimeEx() which returns ICorRuntimeHost Configure CLR as needed via interfaces and/or CorBindToRuntimeEx API From VB6 Co-create CorRuntimeHost from VB6 Load managed host into default AppDomain Bulk of hosting logic should be here Load and execute managed code from host This can be your code or random add-ins Host can optionally create separate ADs for isolation of components

Benefits And Costs Benefits Provides a great deal of control over CLR Choose CLR version AppDomain usage Garbage Collection mode Loader Optimization Load assemblies via your host Managed code executes natively -- no need for interop registration Assemblies can run against your managed and/or COM object models (via RCWs or PIAs) Great model for hosting managed add-ins and virtual apps Used by ASP.NET, SQL Server and the managed service host in Longhorn Costs Can be complicated

Next Steps Evaluate where & how to integrate managed code Try it out, and let us know the results!

.NET and COM: The Complete.NET and COM: The Complete Interoperability Guide – Adam Nathan Interoperability Guide – Adam Nathan Blogs: Blogs: Newsgroups: Newsgroups: microsoft.public.dotnet.framework.interop microsoft.public.dotnet.framework.interop Web sites: Web sites: CLR SPY & pinvoke.net Add-In

© 2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.