Send a suggestion!

We're building a brand new version of the site, and we'd love to hear your ideas

Members

Technology Zones

IBM Learning Center

Articles

Hosted By

MaximumASP

Info

Rated
Read 21,580 times

Contents

Related Categories

COM Interoperability in .NET Part 2 - The unmanaged code

ggarung

The unmanaged code

Once the assembly is registered and properly installed, the types defined within the assembly can be used from COM as though they were normal COM types. Now you can create a simple VB 6 Standard EXE project type and as I already said confirm whether you set a reference to the new generated type Library. Place this code in the code section and now you see the usage of our .NET type in Classic COM.

Private Sub Command1_Click()
    Dim a As New Calculator
    MsgBox a.Add(100, 100), vbInformation, "ADDITION (100,100)"
    MsgBox a.GetType, vbInformation, "INFORMATION-TYPE"
    MsgBox a.Hello("India"), vbInformation, "STRING"
    MsgBox a.Subtract(100, 1), vbInformation, "SUBTRACTION(100-1)"
    Dim i As Imuldiv'INTERFACE
    Set i = a
    MsgBox i.Multiply(100, 100), vbInformation, "MULTIPLICATION(100*100)"
    MsgBox i.Division(100, 100), vbInformation, "DIVISION(100/100)"
End Sub

Summary

A lot of companies have spent a great amount of money and time in COM components. With introduction of .NET people are worried about the future of COM. Microsoft has recognized this and provide means to use classic COM components in .NET code and vice versa.

G.Gnana Arun Ganesh is the Administrator and the Founder of ARUN MICRO SYSTEMS (www.arunmicrosystems.netfirms.com). He has been programming in C++, Visual Basic, COM, Java and Microsoft Technologies for 3+ years. Arun's background includes Bachelor degree in ECE.He is one of the Top authors writing articles in C# and .NET in various websites. He is an Active person in the panel of Technical Reviewers in Prentice Hall Publishers and Sams Publication. In .NET the last book he reviewed is the "C# how to program" written by Harvey and Paul Deitel. You can contact him through ggarung@rediffmail.com

Comments