Skip to content

NuGet access

The DHI MIKE APIs for MIKE Core and MIKE 1D are available as NuGet packages publicly from http://nuget.org. All available NuGet packages from DHI can be found from DHIGroup profile on NuGet.

The NuGet packages can be used directly from within Visual Studio. It is also possible to use the nuget.exe from nuget.org/downloads to retrieve the content of the packages.

Content of packages

Build, run, deploy

The MIKE Core components (DFS, PFS, Projections etc.) contain all binaries required to build, debug, run and deploy applications based on the MIKE Core packages. You do not need any other MIKE software installed in order to run your application that uses MIKE Core, just grab everything from the build output folder, and you should be good to go. To check exactly what is part of the MIKE Core, check the dependencies of the NuGet package DHI.MikeCore. You may need to install Microsoft Visual C++ redistributables, see section below.

Build only

The MIKE 1D packages are mostly "build-only" packages, i.e. you can build an application based on the MIKE 1D packages, but you need a MIKE installation (MIKE Zero/MIKE+/MIKE URBAN) and use of DHI.Mike.Install to find the MIKE installation, in order to run and debug tools based on the MIKE 1D packages. The exception of "build-only" is the MIKE 1D ResultData package (reading of 1D result files, res1d, res11, prf, crf etc.), which also does not require a MIKE installation.

Requirements

Targeting 64 bit only

Most of the DHI MIKE nuget packages are 64 bit only. Some contain native libraries that are available in a 64 bit version only. So be sure to target x64 in your C#/.NET project (Visual Studio), otherwise the native dll are not copied to the output bin folder.

Managing NuGet packages as PackageReference

When managing NuGet packages in Visual Studio, be sure to use the PackageReference format (and not the packages.config file). Use of PackageReference will copy all native binary files to the build output folder. If using packages.config file, binary files may not be copied correctly to the output folder, and some manual copying of the remaining file can be necessary.

For a help on how to use PackageReference format, check e.g. Migrate to PackageReference with 3 clicks

Microsoft Visual C++ redistributables

The MIKE software native components (DFS, EUM, Projections and others) require Microsoft Visual C++ redistributables for Visual Studio 2017 or later in order to run.

These redistributables are often already installed. They are installed automatically by MIKE Zero, MIKE Urban or MIKE SDK. In case they are not already installed, they can be downloaded from:

Troubleshooting

My application will not run (MIKE Core)

Check the following:

  • Your application is targeting x64 (64 bit)
  • You have Visual C++ redistributables installed. If not, download and install, or install a MIKE product (MIKE SDK, MIKE Zero, MIKE URBAN).
  • For .NET Core projects, a publish step is required. You must publish to win-x64.

My application will not run (MIKE 1D)

Check the following:

  • Your application is targeting x64 (64 bit)
  • You have MIKE 1D installed (MIKE Zero or MIKE URBAN).
  • You are using DHI.Mike.Install to locate the MIKE installation, and check that the versions are consistent between the installation, the MIKE nuget packages version and the version used in DHI.Mike.Install.

FileNotFound exception: XYZ.dll was not found

For MIKE Core based applications, the file is missing from the output folder.

This can happen if

  • Managing NuGet packages using packages.config instead of PackageReference. Check the section above on "Managing NuGet packages".
  • For .NET Core projects, a publish step is required. You must publish to win-x64.

For MIKE 1D based applications.

  • MIKE 1D must be installed. Check that either MIKE Zero or MIKE URBAN is installed.
  • Check that the version of MIKE 1D installed is matching the version that the application was build against. If upgrading MIKE software to a new release, the application must be rebuild based on new NuGet packages.
  • Be sure to use DHI.Mike.Install, to locate and use files from the MIKE installation folder, and check that the versions are consistent between the installation, the MIKE nuget packages version and the version used in DHI.Mike.Install.

BadImageFormatException is thrown

You application is a 32 bit application. DHI MIKE are all 64 bit applications, so be sure to target x64 in your application.

System.TypeInittializationException: The type initializer for XXX threw an exception

This happens when you application cannot find or use the DHI MIKE native libraries. There is usually an inner exception stating either:

  • FileNotFound: XYZ.dll was not found: Check above
  • BadImageFormatException: check above.