Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
COM/COM+ obsolete?
Message
From
31/07/2001 05:22:28
 
 
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Miscellaneous
Thread ID:
00537440
Message ID:
00537653
Views:
16
This message has been marked as a message which has helped to the initial question of the thread.
Brian,

COM is such an important part of the .NET framework that MS decided to give us the COM interopability layer. They even consume and use COM interfaces themselves in the CLR, just look at some of the IL through the ILDASM utility.

To use an existing components functionality in your .NET application you need to generate metadata that is in turn used by the runtime to generate a runtime callable wrapper. We do this using a utility supplied with the framework called tlbimp.exe and can be used like this:
tlbimp component.tlb /out:component.dll
If you now go look at component.dll through the ILDASM utility you will see that your interfaces are now exposed in a .NET consumeable way.

To expose .NET functionality to a COM aware client you use the REGASM utility provided with the framework. If we use the following .NET code as a quick example.
using System;
using System.Windows.Forms;
using System.Runtime.InteropServices;


[ClassInterface(ClassInterfaceType.AutoDual)]
public class SampleComponent
{
   private float m_fSample = 0;
   
	
   // Public Constructor
   public SampleComponent()
   {
      m_fSample = 100.0f;
   }
	
   // COM property Sample accessor(s).
   public float Sample
   {
      get { 
         return m_fSample; 
         }

      set { 
         m_fSample = value;
         }
   }
}
To generate a COM compatible type library you would do something like this:
regasm SampleComponent.dll /tlb:SampleComponent.tlb
Now we can consume this using VB, VFP or Visual C++ in the same way we consume a VFP, VB or ATL COM object.

The example above is untested and only scratches the surface of the COM interop. layer but should give you an indication of just how important COM is to the future of the MS .NET strategy.

HTH
Neil
Previous
Reply
Map
View

Click here to load this message in the networking platform