This is a mirror of official site: http://jasper-net.blogspot.com/

Universal COM Callable Wrapper

| Tuesday, October 19, 2010
Introduction

Generic COM Callable Wrapper for any .Net object, class, or type. This is a language-independent COM class library allowing virtual porting of most Microsoft .Net framework classes and types into any COM-aware language. On Windows OS's, if your language of choice can at least work with COM, theoretically with this library, you can now work with any Microsoft .Net class, type and object. It was written in VB using a regular text editor, and compilable using Microsoft's VB compiler.

The compiled dll is meant to be registered as a COM class, making it available in any COM-capable language. Under the hood, the universal functionality is made possible using standard runtime calling and declaration methods. Reflection is used to load assemblies and create wrapped objects and static classes of types declared by you at runtime within the Universal_CCW_Factory class. The standard CallByName() function is used inside the Universal_CCW_Container class to work with a wrapped object's properties and methods. More Reflection methods are used inside the Universal_CCW_Container class to work with a wrapped static type's fields, properties, and to call its methods. For events: an anonymous sub within the Universal_CCW_Container wrapper class acts as a universal Delegate/event handler method. Event handling is nothing new: the anon sub simply copies information about the triggered event to a Queue-type property of the main Universal_CCW_Factory master object.

Regarding events, handling is currently limited to EventHandler and ComponentModel.CancelEventHandler handler types (or any that can comfortably convert down to). This is because I've not yet found a way to force the handler type at runtime. Regarding certain traits of .Net classes that may initiate internal loops, such as the Run method of the Application class: objects and classes exist within a VB.Net trapped environment, meaning you will not be privy to any internal processing going on. An internal loop triggered by any method of the underlying object or class will freeze your project. There is no "main" sub. Therefore, if your project calls for such specialized handling, you should consider making a specialized wrapper.

The form screen-shot below is an example of what can be done using this library under PHP command line scripting. A Windows form is created with textbox and button controls, button click event monitoring, and incorporating a color-picker dialog box to print the decimal value of the chosen color back to the textbox.

Read more: Codeproject

Posted via email from .NET Info

0 comments: