Skip to main content

.Net Interoprability

You would have theoretically learnt the .Net supports Interoperability feature. We know Interoperability is the ability of two systems to communicate with each other, The first system could be built on .Net framework and the other system can be of some other technology.
Lets practically learn the concept of .Net Interoprability using Visual Studio tool between tow languages C# and VB in .Net.

Step 1:
Create a simple csharp .Net library which contains a method sayHello() as shown below :



using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace interoperability_CsLibrary
{
    public class Class1
    {
       public void SayHello()
        {
            Console.WriteLine(“Hello”);
            Console.ReadLine();
        }
    }
}







Step 2:
Lets see how to call the C# sayHello() function in a VB project,
Create a simple VB code Module1 where I want to use the csharp method.
Import the library interoprability_CsLibrary and invoke the method.



Imports interoperability_CsLibrary
Module Module1
  Sub Main()
     Dim obj1 As Class1
     obj1 = New Class1()
     obj1.SayHello()
 End Sub
End Module

Here you can see that ,we can use csharp method 'sayHello()' inside VB project!!!!,

But how it is possible!, The answer is .net converts the them into Intermidiate language (IL).

Comments

Popular posts from this blog

Creating package in Oracle Database using Toad For Oracle

What are Packages in Oracle Database A package is  a group   of procedures, functions,  variables   and  SQL statements   created as a single unit. It is used to store together related objects. A package has two parts, Package  Specification  and Package Body.

Resolving 'Setup Account Privileges' error while installing SQL Server

A new installation of Microsoft SQL Server 2012 or Microsoft SQL Server 2008 R2 fails You see the following error message when you try to install a new instance of SQL Server 2012 or SQL Server 2008 R2: Rule "Setup account privileges" failed.

Creating Oracle stored Procedures using TOAD for Oracle

In a database management system, a  stored procedure  is a set of Structured Query Language (SQL) statements with an assigned name that's stored in the database in compiled form so that it can be shared by a number of programs. The use of  stored procedures  can be helpful in controlling  access to data, preserving  data integrity  and  improving  productivity.