Static libraries and C#
-
Hello, I would like to know if there is some way to use a static library (a .LIB developed using C++) from C#. Any idea? Regards Severino
Isn't possible. .NET uses assemblies that contain dependency references, assembly attributes, modules (what actually contain the code), embedded resources, and a manifest that lists it all. This does imply, however, that you could write a library and compile it as a module (only possible with the command-line compiler, csc.exe (C# compiler) using the
/t:module
parameter. You can then compile an assembly that contains your code plus this module. It's not quite the same thing, but the result is pretty much the same. Again, this is only available with the command-line compiler. VS.NET doesn't support this. Doing things this way will result in an assembly with two different modules. There is an article at an old hang-out that describes writing assemblies with modules in different languages. The principal is the same even if you use the same language, though: http://www.devhood.com/tutorials/tutorial_details.aspx?tutorial_id=466[^].-----BEGIN GEEK CODE BLOCK----- Version: 3.21 GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++ -----END GEEK CODE BLOCK-----
-
Hello, I would like to know if there is some way to use a static library (a .LIB developed using C++) from C#. Any idea? Regards Severino
Two options: 1) Compile it into a DLL. 2) Write a wrapper using Managed C++.