.NET mixed multi-file assembly

I need to create a .NET assembly made up of 2 modules: 1 internal (in the DLL) with native code and 1 external (in the .netmodule file).

This would be easy to do except for the native part.

The C # compiler can do this ( this is what I want, but with native code ):

csc /t:library /out:foobar.dll foo.cs /out:bar.netmodule bar.cs
-foobar.dll (contains assembly manifest and foo IL)
    -internal module foobar.dll (contains foo IL)
    -external module bar.netmodule (contains bar IL)

      

The C ++ compiler / linker will put everything in 1 inner module.

cl /clr /LD foo.cpp /link bar.netmodule /LTCG
OR link /out:foobar.dll foo.netmodule bar.netmodule
-foo(bar).dll (contains IL for both foo and bar, as well as assembly manifest)

      

Assembly Linker only executes external modules:

al /out:foobar.dll foo.netmodule bar.netmodule
-foobar.dll (only contains manifest)
    -external module foo.netmodule (contains foo IL)
    -external module bar.netmodule (contains bar IL)

      

I've also tried tweaking IL manually, but ILDASM and ILASM don't have the ability to round off native code:

ildasm foobar.dll /out=foobar.il
ilasm /dll foobar.il
-lots of errors

      


To clarify, I want:

-foobar.dll (contains assembly manifest and foo IL AND NATIVE CODE)
    -internal module foobar.dll (contains foo IL AND NATIVE CODE)
    -external module bar.netmodule (contains bar IL)

      

+2


source to share


3 answers


Henk is already on the right track. You can create .netmodule

for input only to create assemblies. An assembly is the smallest executable in the .NET environment. An assembly can consist of one or more physical files. It can contain multiple resources: resource files, network modules, and native DLLs. A network module cannot be deployed by itself, it must be linked to an assembly.

Now that we have this, try focusing on what you need. Are you trying to create a multi-file assembly? It is possible. Here's a pretty old but still useful post for multi-module builds. Or are you trying to create network modules that can be used as libraries? As this is not possible as network modules do not contain assemblies.



If that doesn't answer your question, can you explain in more detail what you want the end result to be and / or how you expect to use it?

+3


source


It looks like this issue has been resolved in System.Data.Sqlite . See file SQLite.Interop / SQLite.Interop.2010.vcxproj .



In the element, <Link/>

you need to specify the network modules in the module <AdditionalDependencies/>

.

+2


source


Disclaimer: This is untested.

Are you looking for the correct cl compiler option ?

cl /clr:pure /LN Stringer.cpp
cl /clr:pure Client.cpp /link /ASSEMBLYMODULE:Stringer.netmodule

      

I'm surprised that the link.exe tool in the link provided by Abel didn't work for you.

+1


source







All Articles