To manage the complexity of long computer programs, computer programmers often adopt object-oriented programming techniques. With these techniques, a computer program is organized as multiple smaller modules called objects. An object is a unit of code comprising both routines and data and is thought of as a discrete entity. These objects perform specified functions and interact with other objects in pre-defined ways. Objects communicate with each other through interfaces. Each object may have multiple interfaces. An interface exposes and defines access to the object's public routines and data. Put another way, an interface can be considered as the definition of an expected behavior and expected responsibilities. One of the advantages to interfaces is that a client object can continue to access the methods of a server object that are exposed through the interface, regardless of whether the underlying code in the object is updated or changed for another reason.
One of the primary benefits of object-oriented programming is that the objects can be easily and affordably adapted to meet new needs by combining them in a modular fashion. The structural foundation for an object-oriented language is the object model. The Component Object Model (COM) produced by Microsoft Corporation of Redmond, Wash., is an example of an object model.
COM is a software architecture for creating and using objects, which makes software easier to write and reuse. In COM, an object is some piece of compiled code that provides some service to the rest of the system. Services are used in a standard way, regardless of location. COM allows an object to expose its functionality to other objects and to host applications. In this manner, COM allows objects made by different software vendors to be combined into a variety of applications.
COM defines a binary standard for component interoperability (e.g., for function calling between components) and is not dependent on any particular programming language. In this manner, binary executables are able to interoperate. Thus, COM can be used with any programming language that uses a binary standard, such as Visual Basic, JAVA, and C++.
In COM, applications interact with each other and with the system through collections of functions called interfaces. A COM interface is a strongly-typed contract between software components to provide a small but useful set of semantically related operations or methods. Thus, in COM, an interface is a related group of functions and is the binary standard through which objects communicate. As noted above, an object can, and typically does, implement more than one interface. Every interface has its own identifier, a globally unique ID (GUID). A GUID is an integer (typically a 128-bit integer) that is guaranteed to be unique in the world across space and time. GUIDs are used to identify every interface and every component object class. Human-readable names are assigned only for convenience and are locally scoped. This helps to ensure that COM components do not accidentally connect to the wrong component, interface, or method, even in networks with millions of component objects. Thus, developers create their own GUIDs when they develop component objects and custom interfaces. Through the use of “defines”, developers do not need to be exposed to the actual (128-bit) GUID. Thus, if a developer creates a new interface, he must also create a new identifier for that interface. When a developer uses an interface, he must use the identifier for the interface to request a pointer to the interface. This eliminates naming conflicts that would result in runtime failure.
It is noted that COM interfaces are not versioned, which avoids version conflicts between new and old components. A new version of an interface is an entirely new interface and is assigned a new unique identifier.
While COM objects have been fundamental to programming for many years, applications designed for use with other platforms, such as the .NET platform produced by Microsoft Corporation of Redmond, Wash. and described in PCT Publication WO 01/98936 having an international filing date of Jun. 22, 2001 and incorporated herein by reference, offer many advantages.
Code developed for the .NET platform is referred to as managed code, and contains metadata (data about data) that is used by the common language runtime. Data used by .NET applications is called managed data because the .NET runtime manages data-related tasks such as allocating and reclaiming memory, and type checking.
As noted above, COM provides a binary standard between two objects. However, .NET is a logical standard and not a binary standard, and accordingly is a different platform than COM.
An assembly is the primary building block of a .NET platform application. It is a collection of functionality that is built, versioned, and deployed as a single implementation unit containing one or more files. Interoperability marshaling is the process of packaging parameters and return values into equivalent data types as they move to and from COM objects.
.NET applications share a set of common types that allow interoperability of objects, regardless of the programming language used. The parameters and return values of COM objects sometimes use data types that are different than those used in managed code.
Conventionally, for a user to map one standard to another standard (e.g., map COM object members to equivalent .NET managed members), the user would have to manually map the new standard to the old standard. The manual method for exposing a class from the .NET platform to COM is very complex and requires extensive knowledge about COM programming. To expose a .NET object to COM, the .NET assembly needs to include the descriptions of the objects in the form of interfaces that COM understands. That consists of a number of interfaces and attributes. The developer would have to manually create the class interface and the events interface and would need specific knowledge of .NET interop to add the necessary interop attributes to the class and interfaces. Additionally, maintaining the COM interfaces and attributes during the development cycle is difficult and the chances of making a mistake are high.
Another conventional approach is to use the default “auto-dual” class interface support provided by the .NET runtime, but this has some deficiencies: (1) it does not provide “events”, which is generally unacceptable to a user, and (2) it breaks down over time because any public change to a base class changes the default class interface. Yet another prior art approach is to generate the interface code and inject it into a user's source file. This is not desirable because it intrudes on a user's code.
In view of the foregoing, there is a need for systems and methods that overcome the limitations and drawbacks of the prior art.