Wednesday, January 19, 2011

Interoperability

Cross Language Interoperability
Interoperability is system that works together. Language Interoperability gives ability to user to interact with code which is written in different language. Common Language Runtime provides built-in support for Language interoperability, but it does not guaranty that code written in one language can be used in other language. To ensure that language of one code can interact with code of another language, a set of language features and rules for using them has defined that is Common Language Specification.

Example
Let make a program to write code in VB and interact with c#. Lets create a class in VB and use it in C#.
Create a New Program and select VB language and Class Library from Templates


Now Create a New C# Console Application then go to solution explorer and right click on your project then go to Add Reference then click browse tab. Now open you project (which was created in VB) then open Bin then Debug. Inside debug you will see dll file of you VB project, add this file to your project.



After adding dll file you can use VB project in c#. 


Before creating instance of class (VB) use namespace of you project (i.e using interoperability1) or you can also create instance by calling fully name (i.e interoperability1.Class1 objEmp = new interoperability1.Class1();).

  

No comments:

Post a Comment