How to Share and Reference .NET Assemblies

Challenge
 

Translate working sets of .class files into assemblies or combine .NET assemblies and Java .class files into a .NET executable or assembly. Assemblies are useful because they can be shared and are loaded on demand by the Common Language Runtime (CLR)*.

 

Solution
 

Use the Jblmp utility (the default J#* installation installs JbImp into the C:Program FilesMicrosoft Visual J# .NETFrameworkBin folder. You need to ensure that this folder is on your PATH).

Any application or assembly running under the CLR can contain references to assemblies created using JbImp, making it feasible, for example, for a C# application to call code that was originally developed and compiled using the JDK. The following command converts four of the five .class files that were created in the separate item, "How to Convert Java .class Files to .NET Executables" into an assembly (note that you use the /target:library option to create an assembly):

 

jbimp /target:library /out:DotNetGui.dll GuiApplication.class
   GuiApplication$1.classGuiApplication$OnMouseEnteredHandler.class
   GuiApplication$OnMouseExitedHandler.class


  JbImp also allows you to combine .NET assemblies and Java .class files into a .NET executable or assembly; use JbImp's /r option to reference the assemblies (make sure the name of the executable is different from the name of any referenced assembly). Notice that assemblies referenced by JbImp do not have to be created using JbImp, which allows an application originally written in Java* to make use of code written in other languages running under .NET. For example:

jbimp /target:exe /out:SecondDotNetApplication.exe 
r:DotNetGui.dll GuiApplicationLauncher.class


  Using the IL DASM tool to analyze a .NET executable and identify dependencies upon other assemblies is covered in a separate item, "How to Inspect the Internal Structure of a .NET* Executable."

 

Source
 

Integrating Java* and Microsoft .NET*

Pour de plus amples informations sur les optimisations de compilation, consultez notre Avertissement concernant les optimisations.