1

Quick question, I've been reading about some .Net stuff and the way some people talk implies on me that a .Net library could be used with multiple .Net languages. Maybe it's just wishful thinking on my part lol. For instance could I use the Tao Framework, programmed in C#, with the Boo .Net language?
The only way I could explain it is if the library is compiled to bytecode to run in .Net and can be used with any language that also compiles too. I don't know very much about .Net though ^-^

Thanks

Isaiah
  • 1,995
  • 2
  • 18
  • 29
  • This is correct. Once you compile a library into an assembly (dll) it can be linked with any other .net language. Interoperability is a key strength. Basically just choose the language you prefer - or best suits the particular problem - the resulting compiled code is language independent. – James Gaunt Dec 12 '10 at 21:36
  • That is officially the most awesome thing I've found in a long time! – Isaiah Dec 12 '10 at 21:38

4 Answers4

2

Any assmebly (IL code and manifest) can be used in any .NET language - it doesn't matter what language it was written in, so long as the code is CIL compliant and conforms to the CLS (Common Language Specification).

From MSDN (CLS):

To fully interact with other objects regardless of the language they were implemented in, objects must expose to callers only those features that are common to all the languages they must interoperate with. For this reason, the Common Language Specification (CLS), which is a set of basic language features needed by many applications, has been defined. The CLS rules define a subset of the Common Type System; that is, all the rules that apply to the common type system apply to the CLS, except where stricter rules are defined in the CLS. The CLS helps enhance and ensure language interoperability by defining a set of features that developers can rely on to be available in a wide variety of languages. The CLS also establishes requirements for CLS compliance; these help you determine whether your managed code conforms to the CLS and to what extent a given tool supports the development of managed code that uses CLS features.

Oded
  • 489,969
  • 99
  • 883
  • 1,009
  • Again extremely awesome, I mean coming from python and lisp, this is really cool – Isaiah Dec 12 '10 at 21:48
  • @Isaiah - MS designed it that way, since they wanted to have both C# and VB.NET using the same base libraries. – Oded Dec 12 '10 at 22:06
  • One typical break is that c# is case sensetive, vb is not.... if you create a type in c# that exposes members that only differentiates in casing it will be marked as CLS non compliant and can't be used. – Pauli Østerø Dec 12 '10 at 22:48
1

If I understood your question right, then you can create a .NET library in, say, C# or Delphi Prism, compile it to IL and get an assembly. Then you can reference and use this assembly in your VB.NET project.

Eugene Mayevski 'Callback
  • 45,135
  • 8
  • 71
  • 121
1

There are limits to interoperability. In particular if the type system underlying different languages differs significantly. But Boo and C# are very similar apart from the syntax, so there should be no problems between these.

CodesInChaos
  • 106,488
  • 23
  • 218
  • 262
  • I like boo alot but what about, say if I try out... ironScheme? – Isaiah Dec 12 '10 at 21:58
  • One typical break is that c# is case sensetive, vb is not.... if you create a type in c# that exposes members that only differentiates in casing it will be marked as CLS non compliant and can't be used. – Pauli Østerø Dec 12 '10 at 22:47
0

We use C# helper libraries in our VB.Net project without issue - A single project can only handle a single language but a solution can contain multiple projects each using their own language (or reference any assembly written in any language that compiles to MSIL) with full VS debugging functionality

Basic
  • 26,321
  • 24
  • 115
  • 201