Skip to content

MIKE Core SDK

MIKE Core SDK include the components that are built to access native file formats and functionality directly, and typically exposes the data and functionality in APIs that are specifically tailored for the entities they target.

Some of them serve as the building blocks in the repositories of domain services, while other serves their own purpose, and may be used directly. They all origin from the classical MIKE code base, and can all be accessed directly from .NET.

Core libraries include the following components:

  • DFS API: This API allows the user to create, read and edit the dfs0, dfs1, dfs2, dfs3 and dfsu file formats.

  • PFS API: The PFS API can read, edit and write files in the DHI PFS format. Files in the PFS format typically serves as configuration files to the MIKE models, including MIKE21, MIKE3, MIKE SHE, MIKE HYDRO, MZ Toolbox, the Plot composer and many others.

  • Projections API:

  • MzChart API: MzChart is the underlying chart component used in most MIKE ZERO charts and maps, including the Grid editor and Plot composer. When used as a stand-alone component, it allows the user to generate and style maps (bitmaps) generated from a range of dfs and mesh file formats.

Getting Started

Creating a Project in Visual Studio or SharpDevelop

This section describes how to make a small console program in Visual Studio or #develop (SharpDevelop) that loads a dfs file. The procedure for the two developer environments are very similar

Prerequisites:

  • A MIKE Powered by DHI product that includes the DHI.Generic.MikeZero.DFS

  • .NET 4.0 or later.

  • Visual Studio, the free Express version should suffice, or #develop.

To create and setup a project in Visual Studio:

  1. Open Visual Studio

  2. a) Visual Studio: Select ‘File’ – ‘New’ – ‘Project’ and select a ‘Visual C#’, ‘Windows’, ‘Console Application’. Find an appropriate name and location for your project.
    b) SharpDevelop: Select ‘File’ – ‘New’ – ‘Solution’. Select ‘C#’, ‘Windows Applications’, ‘Console Application’. Find an appropriate name and location for your project.

  3. Right click on the ‘References’ and select ‘Add Reference’. Select the ‘Browse’ tab. Go to the MIKE SDK bin folder, which is usually located in the default DHI installation folder under Program Files (x86)

Find and locate the file DHI.Generic.MikeZero.DFS …

Select it and press ok.

  1. Do the same for

    DHI.Generic.MikeZero.EUM

Now the project is ready. It has created a ‘Program.cs’ file containing a Program class with a Main function. When adding the appropriate using directives, the DFS API is readily available.

Example, modify the ‘Program.cs’, to contain:

   using System;
   using DHI.Generic.MikeZero.DFS;
   using DHI.Generic.MikeZero.DFS.dfs123;
   namespace ConsoleApplication
   {
    class Program
    {
        static void Main(string[] args)   
        {
            Dfs2File dfs2File =
            DfsFileFactory.Dfs2FileOpen(\@’c:\\Work\\test\\MyFile.dfs2);
            IDfsAxisEqD2 axis = (IDfsAxisEqD2)dfs2File.SpatialAxis;
            Console.Out.WriteLine(Size of grid: {0} x {1}, axis.XCount, axis.YCount);
        }
    }
   }

This will print out the size of a 2D equidistant axis.

Using the Command Prompt

It is possible to compile the above Program.cs without Visual Studio. In a command prompt, locate the folder with the Program.cs file and issue:

C:\Windows\Microsoft.NET\Framework\v4.0.30319\csc.exe

/r:"C:\Program Files (x86)\DHI\2017\MIKE SDK\bin\DHI.Generic.MikeZero.DFS.dll"

/r:"C:\Program Files (x86)\DHI\2017\MIKE SDK\bin\DHI.Generic.MikeZero.EUM.dll"

/platform:x86

Program.cs

Paths may need to be updated. That will build a Program.exe that can be run. The platform argument is only required if you want to build an application that always runs in 32 bit mode.

Such a command can be issued on any Windows computer with .NET installed.