The .NET Core runtime does not contain all the APIs that applications use. This is because .NET Core’s runtime is indeed just the “core” set of APIs; it is designed to be as minimal as is practical, and additional “extensions” are only brought in when needed. These extensions are generally organized in “packages” and are stored in repositories in the cloud. A package manager called NuGet is used to download them from the cloud and incorporate them in .NET Core projects. While it is generally used as a Visual Studio extension, it can also be run from the command-line.
When JNBridgePro is used in .NET Core projects, it requires additional APIs found in extensions, and those extensions must be included in your application’s Visual Studio project. In particular, the following packages must be downloaded and included in the application’s project:
The above packages support application configuration using JSON files. (Note that the Users’ Guide mentions a fourth package, Microsoft.Extensions.Configuration.Abstractions, that must be included. However, the two Microsoft extension packages depend on this fourth package, so that additional package will automatically be downloaded and included.)
When creating your application, you can add the NuGet packages through the Package Manager Console. Open it by selecting from the Visual Studio menu bar Tools→NuGet Package Manager→Package Manager Console. You should see the following window:
Make sure that the “Default project” is set to whatever project is using JNBridgePro for its Java/.NET Core interop. The window contains a PowerShell command-line interface. Enter the following lines at the prompt, with a line feed after each, and waiting for NuGet to return before entering the second line:
Once this is done, the packages will be part of the project, and will be included when you build the application:
If you prefer a GUI rather than a command-line interface of the Package Manager Console, a GUI tool is available. From the Visual Studio menu bar, select Tool→NuGet Package Manager→Manage NuGet Packages for Solution….
A GUI window will come up in Visual Studio:
Select the Browse tab, and enter the name of a package that you want to download and include. You can simply add enough of it to narrow down the list:
For each package that you want to include, select it. On the right side of the window, you will see the actions that you can take:
Make sure that a check mark is placed next to the project representing the application using JNBridgePro, and click on “Install.” The package and all dependencies will be added. Do this for both packages: Microsoft.Extensions.Configuration.Binder and Microsoft.Extensions.Configuration.Json. Repeat the process for Newtonsoft.Json. The packages will now be included in your project, and will be used when you build your application.
Note that in JNBridgePro 10.0 and 10.1.0, we have included in our installation the DLLs from the packages as a convenience to the developer. However, we recommend that you download the latest packages through NuGet, since you will be assured of getting the latest bug fixes and improvements. In upcoming releases, we plan to stop distributing the convenience DLLs.
For more information on the package management console, see https://docs.microsoft.com/en-us/nuget/reference/powershell-reference. For information on using the NuGet GUI interface, see https://docs.microsoft.com/en-us/nuget/consume-packages/install-use-packages-visual-studio.