ASP DOT Net - Interoperability - Managed Code to Unmanged Code - Missing Piece.

Simply put, interoperability is the process of allowing codes or assembly written within the ASP Dot Net Framework to be called by unmanaged code or Win32 Apps. To bring this closer to real life situation -  I am part of a team working on a Delphi based - Windows Messaging centric - closer to rocket science code - kind of application. The whole thing looked like magic to me at my first encounter and I could not  imagine anybody sitting down and coming up with that kind of architecture.

Over time, I realized it was not as difficult or magical as I initially thought but nonetheless, I still give kudos to the initial architects of the system - the guys are really smart and to boil it down, it comes to doing asynchronous programming  where execution of certain codes is not directly at the instigation of the user but rather based on events controlled by the operating system and cleverly managed by the Windows messaging system as well as COM implementation. I am actually bereft of words in describing the application - you need to be involved to actually appreciate the ingenuity that went into the design, architecture and implementation - it is a thing of beauty.

Anyway, back to interoperability,  we implemented a home grown editor that allowed for all kinds of "slice and dice" manipulations of the RTF stream to achieve specific requests by the end users. When we upgraded to Delphi 2010 ( currently Delphi version is XE), we found out that certain features were no longer possible or/and available because of the upgrade except we upgraded the core component of the editor which we were not willing to do. We tried to improvise by writing some custom code to convert/massage  from the old editor component to the new one we were using and it was just  a game of chance - some stuff converted fine while others did not leading to users disenchantment.

We now decided to look at the ASP Dot Net Framework as we found some components written for WinForm development that were perfect fit for our needs. The issue then was how can we consume ASP Dot net Framework code in Delphi without breaking the bank?

Therein comes Interoperability. There are a lot of literature out there ensconcing the "how to" of this framework and the best can be found on MSDN.  There is also a nice article by Brian Long detailing how to do this the Delphi way - Although he used Delphi For Dot Net - instead of say C#.

The only problem is that  -  all of them failed to mention some important things needed to have the Type library publish the classes for CCW - Com Callable Wrapper Objects  and this is the thrust of this article. You need to do the following if you are using VS2010 - Set the  ComVisible Attribute to true in the assembly file -

[assembly: ComVisible(true)]

You  may also need to modify the following to get it to work -

change :

[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

to
[assembly: AssemblyVersion("1.0.0.1")]
[assembly: AssemblyFileVersion("1.0.0.1")]

Comments

Popular posts from this blog

Decompiling Delphi - 3

Decompiling Delphi - 2

Artificial Intelligence, Oxymoron and Natural Intelligence