clr - How does language interop work in .Net? -
in .net framework, under impression can write library in 1 language (say c++), import code , use library cleanly in other c# project (assuming both target same framework version).
however, don't understand how works when there methods defined in c++ wouldn't make sense in other language c# or vb.net, such method parameter takes struct isn't pointer.
perhaps example doesn't hold due limited knowledge of clr languages, have assume there things 1 language can can't -- , don't how these discrepancies dealt with.
it possible create method, class, struct, type or whatever in 1 .net language cannot called directly. calling indirectly (by means of reflection, instance) possible.
i.e., if @ compiled c# project, you'll see compiled code contains code weird names , characters in it, supporting generics. 1 such name <module> (including brackets), which, if made public method, can never called c# directly.
language designers decide compile clr must support minimal subset public types. referred cls compliance , a common naming convention, no public pointers or public unsafe members or classes, no names differ case, no public static fields , some more rules. when obey rule guaranteed other .net language can call methods. know how this, because rules laid out , documented.
you can create non-compliant c# code. (usually) compile, not guaranteed compliant languages can call method. same true other languages, including c++.net. microsoft design guideline mark assemblies clscompliant default (whether it's written in c++, vb, ruby doesn't matter).
Comments
Post a Comment