Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.Net and plugin architectures

Following on from Jeff and Joel's discussions of plugin architectures.

Plugins in C++ (using runtime loaded dlls) are always a bit of a pain. You have to do a lot of ground work to enable them and then the plugin must also be written in C++, often even with the same compiler. COM objects and ActiveX solved some of these problems but introduced a few of their own.
Then to add say, a python interface, to a C++ app is a large amount of work.

Am I correct in thinking that all libraries (or assemblies or whatever you call them) written in one .Net language can always be called from another .Net language? And can objects an data types be automatically transferred between them?

Presumably since all .Net languages also use Winforms (or WPF) for the gui, then giving plugins access to the main app's gui is also relatively simple.

Sorry if this is a rather obvious point I'm just an old fashioned C++ programmer. But the ease of reusing existing C++ libraries via C++/CLI has convinced me that C#/.Net might be worth more investigation.

Edit - thanks, I was looking to discuss if plugins were a reason to go .Net . Being able to write ironpython while having my business users able to write a simple plugin in VB and technical users be able to craft something clever in F# without me doing any more work seemed a good reason to switch from C++

like image 390
Martin Beckett Avatar asked Aug 01 '09 18:08

Martin Beckett


2 Answers

Am I correct in thinking that all libraries (or assemblies or whatever you call them) written in one .Net language can always be called from another .Net language? And can objects an data types be automatically transferred between them?

Yes. In .NET, the cross-language compatibility is possible because of CTS (Offer a set of common data types for use across all .NET compliant languages and ensures type compatibility) and CLS (Defines a set of minimum standards that all .NET language compilers must conform to, and thus ensures language interoperability). During compilation, a source code of any .NET-compliant language is converted to Intermediate Language code by the respective language compiler. As all .NET assembly (EXE or DLL) exists as intermediate language, they can interoperate between them. All .NET compliant languages use the same data types and are represented as .NET types only. Therefore whether you are using int in C# or Integer in Visual Basic .NET, in IL it is represented as System.Int32. [Source]

like image 116
bdd Avatar answered Oct 05 '22 08:10

bdd


If you are looking for plug-ins libraries in .NET, there are a couple of options I am aware of:

  • From Microsoft there is MEF
  • From Novell (Mono) there is Mono.Addins

Both are open source, so you can see how they went about creating a plug-in environment.

like image 27
Oded Avatar answered Oct 05 '22 08:10

Oded