Presentation is loading. Please wait.

Presentation is loading. Please wait.

COM and.Net Components By Sam Nasr January 25, 2005 www.ClevelandDotNet.info.

Similar presentations


Presentation on theme: "COM and.Net Components By Sam Nasr January 25, 2005 www.ClevelandDotNet.info."— Presentation transcript:

1 COM and.Net Components By Sam Nasr January 25, 2005

2 What is COM? Common Object Model Common Object Model COM defines a common way to access data and software services. COM defines a common way to access data and software services. Each COM object supports one or more interfaces. Each COM object supports one or more interfaces. Each interface within the COM object supports a number of methods. Each interface within the COM object supports a number of methods.

3 What is COM? COM objects are implemented inside a server. COM objects are implemented inside a server. Each COM object is an instance of a class. Each COM object is an instance of a class. COM objects provide polymorphism, and data encapsulation. COM objects provide polymorphism, and data encapsulation.

4 COM Terminology Interface: a set of methods; contract between client and its components. Interface: a set of methods; contract between client and its components. GUID/UUID: Globally/Universally Unique Identifier. Based on IP address, MAC address, date/time, etc. in the format { }. GUID/UUID: Globally/Universally Unique Identifier. Based on IP address, MAC address, date/time, etc. in the format { }. Transactions: separate units of work treated as one (all or nothing). Transactions: separate units of work treated as one (all or nothing). Monikers: a COM object with a very well defined purpose (create, initialize, and connect to another object). Monikers: a COM object with a very well defined purpose (create, initialize, and connect to another object).

5 Evolution of COM Need for software reuse and code sharing. Need for software reuse and code sharing. COM Evolved from OLE and ActiveX. COM Evolved from OLE and ActiveX. Different programs can share data and services using 1 standard. Different programs can share data and services using 1 standard.

6 Problems of non-standard Code Sharing Distributing objects with their source code. Distributing objects with their source code. Reusing objects across different languages. Reusing objects across different languages. Re-linking or re-compiling an entire application when one object changes Re-linking or re-compiling an entire application when one object changes

7 Features of COM Classes of COM objects are identified by Class Identifiers (CLSID). Classes of COM objects are identified by Class Identifiers (CLSID). GUIDs are used to name Class Identifiers (CLSID). GUIDs are used to name Class Identifiers (CLSID). System Registry is used to map given CLSID to actual component. System Registry is used to map given CLSID to actual component. Use CoCreateInstance to create a new COM object. Use CoCreateInstance to create a new COM object.

8 Features of COM IUnknown supports 3 methods: IUnknown supports 3 methods:QueryInterfaceAddRefRelease Every COM interface has a common first method named QueryInterface. Every COM interface has a common first method named QueryInterface.

9 Advantages of COM Versioning: Versioning: Existing interfaces do not change. Existing interfaces do not change. New functionality offered in new functionality. New functionality offered in new functionality. Results are consistent Results are consistent No relinking/recompiling an application when one object changes. No relinking/recompiling an application when one object changes.

10 Advantages of COM Widely used in Microsofts product line. Widely used in Microsofts product line. Expanding to accommodate Mainframe systems. Expanding to accommodate Mainframe systems. Structured storage allows for data persistence (storage and stream). Structured storage allows for data persistence (storage and stream). Ease of code reuse. Ease of code reuse.

11 Advantages of COM Accessible by all kinds of software components. Accessible by all kinds of software components. Language independent. Language independent. Interfaces provide a universal method of access. Interfaces provide a universal method of access. COM data is encapsulated, and directly accessible. COM data is encapsulated, and directly accessible.

12 Advantages of COM Uniform Data Transfer (UDT): a standard for exchanging information. Uniform Data Transfer (UDT): a standard for exchanging information. Storage/Stream: objects for sharing a single file. Storage/Stream: objects for sharing a single file. Directory Services supply information for clients processes. Directory Services supply information for clients processes.

13 What is DCOM? Distributed Common Object Model Distributed Common Object Model Distributed Component services Distributed Component services Remoting Architecture Remoting Architecture

14 What is MTS? Microsoft Transaction Services Microsoft Transaction Services Handles Transaction Services for COM components. Handles Transaction Services for COM components. Manages resource pooling Manages resource pooling Role Based security Role Based security Administration Administration Just-in-Time Activation Just-in-Time Activation

15 What is COM+? Integration of administration services/features. Integration of administration services/features. Accesible from Administration Tools folder (Component Services). Accesible from Administration Tools folder (Component Services). Included with post Win2000 OSs Included with post Win2000 OSs Load balancing Load balancing In memory database In memory database Object Pooling Object Pooling Queued Components Queued Components Event Model Event Model

16 COM &.Net COM components must be registered prior to use with.Net applications (regsvr32.exe). COM components must be registered prior to use with.Net applications (regsvr32.exe)..Net Assemblies must be registered for use with COM components (regasm.exe).Net Assemblies must be registered for use with COM components (regasm.exe) Regasm.exe must be run in VS.Net Command Prompt window. Regasm.exe must be run in VS.Net Command Prompt window.

17 COM &.Net Interoperability RCW: Runtime Callable Wrappers (INTEROP.COMLib) RCW: Runtime Callable Wrappers (INTEROP.COMLib) DLLHost.exe: host process for handling remote COM calls. DLLHost.exe: host process for handling remote COM calls. TlbImp.exe: Converts COM to.Net Assembly. TlbImp.exe: Converts COM to.Net Assembly.

18 TLBIMP vs. Direct Reference Tlbimp.exe Tlbimp.exe Tlbimp MyCOM.DLL /out:NetMyCOM.DLL (execute in VS CMD) Tlbimp MyCOM.DLL /out:NetMyCOM.DLL (execute in VS CMD) Allows for signing the resulting assembly. Allows for signing the resulting assembly. Resulting code can be used in GAC Resulting code can be used in GAC Direct Reference Direct Reference Easier to use Easier to use Does not allow for signing the assembly Does not allow for signing the assembly Resulting code cannot be placed in GAC or shared with other.Net assemblies. Resulting code cannot be placed in GAC or shared with other.Net assemblies.

19 Additional Info mpare.pdf mpare.pdf mpare.pdf mpare.pdf en-us/dndotnet/html/callnetfrcom.asp en-us/dndotnet/html/callnetfrcom.asp en-us/dndotnet/html/callnetfrcom.asp en-us/dndotnet/html/callnetfrcom.asp en- us/vbcon/html/vbconcominteropinvisualbasicvisualc.asp en- us/vbcon/html/vbconcominteropinvisualbasicvisualc.asp en- us/vbcon/html/vbconcominteropinvisualbasicvisualc.asp en- us/vbcon/html/vbconcominteropinvisualbasicvisualc.asp

20 Job Board Senior Developer - Downtown Cleveland, C#.net and Oracle PL/SQL experience (Job# 2578) Senior Developer - Downtown Cleveland, C#.net and Oracle PL/SQL experience (Job# 2578) Contact Dave Sgro Instructor – CCC Westlake Instructor – CCC Westlake MS2310 ASP.Net and VS.Net Contact Toni Paoletta Developers – Berbee Information Systems.Net Developers – Berbee Information Systems Visit the Careers section at

21 Useful Tools Process Explorer Process Explorer A Task Manager utility that provides more much more info than the standard windows utility. Fiddler HTTP Debugger Fiddler HTTP Debugger Allows you to inspect all HTTP Traffic, set breakpoints, and "fiddle" with incoming or outgoing data. API-Guide API-Guide A comprehensive API utility complete with documentation and examples.

22 Upcoming Events Feb 3 rd : MSDN Event Feb 3 rd : MSDN Event Topic: WinForms, ASP.Net, VS Team Systems Feb 12 th : GCPCUG General meeting Feb 12 th : GCPCUG General meeting Topic: consumer electronics Feb 22 nd : C#/VB.Net Meeting Feb 22 nd : C#/VB.Net Meeting Topic: SQL Server 2005 Reporting Services


Download ppt "COM and.Net Components By Sam Nasr January 25, 2005 www.ClevelandDotNet.info."

Similar presentations


Ads by Google