DHI.Mike.Install¶

To help script or application to locate .NET assemblies in the MIKE installation bin folder, we have added a single assembly to the GAC (Global Assembly Cache) which will do the trick. It is called DHI.Mike.Install. It is required to use one of the Setup methods from there before any usage of MIKE components in scripts or tools.

It is not required to use DHI.Mike.Install if all the MIKE components are deployed with your application and in the same folder as your application. One example of this is when building a tool in Visual Studio using the NuGet packages, because then all required files are already present.

Use DHI.Mike.Install to locate the MIKE installation bin folder.¶

To locate the latest MIKE installation bin folder containing MIKE Core components:

MikeImport.SetupLatest(MikeProducts.MikeCore)


This is the most common way to enable MIKE Core in a scripting environment, and works with any recent version of MIKE libraries.

If more than one version of MIKE Software is installed, it is possible to load a specific version - with a bit of error checking:

if (!MikeImport.Setup(18, MikeProducts.MikeCore))
throw new Exception();


In case of xcopy deployment, it is possible to specify the root folder explicitly, as e.g.:

MikeImport.SetupInstallRoot(@"C:\Program Files (x86)\DHI\2019");
MikeImport.SetupInstallRoot(@"C:\folder\with\MIKE\Core\bin");


This must be called before any method using MIKE components. From C# we recommend doing this in a static constructor, which will also make sure it is only done once.

Make sure to work in a 64 bit environment, since the MIKE components are only available in 64 bit versions.

How it works¶

The way that the .NET runtime searches for .NET assemblies is different from how a "normal"/unmanaged/C/C++ program searches for dll's and files. The .NET runtime does NOT use the PATH environment variable for finding other .NET assemblies, so updating the PATH variable is not sufficient. But it is ALSO required to update the PATH variable, in order to find the native dll's and files in the MIKE installation bin folder. DHI.Mike.Install does two things:

• Hooks up on AppDomain.AssemblyResolve event and searches in the MIKE installation bin folder.