Skip to content
Harri Pitkänen edited this page Dec 19, 2015 · 2 revisions

Installing .NET interface for Voikko

.NET interface (written in C#) has been part of libvoikko since version 3.3. It is developed and tested with Mono on Linux but should also work with other platforms and .NET implementations. If you notice compatibility issues, please file a bug report.

Installing the native library and dictionary data

You need to have the native libvoikko library available in a place where the OS specific library loading mechanism will find it. On Linux installation through the package manager will work (on Ubuntu 10.10 installing Finnish language support is enough). On Windows you should place the library in one of the directories within the PATH environment variable.

Dictionaries (voikko-fi or any zhfst speller) should be installed just as with any other application that uses Voikko.

Building the .NET assembly

Our .NET code is written in C#. The project and solution files that control the build process are created with MonoDevelop. Since MonoDevelop attempts to produce project files that are compatible with Microsoft Visual Studio it may be possible to build the code in Visual Studio. At the moment we only support MonoDevelop as a build tool.

The sources are located within libvoikko source package (or Git clone) under directory cs. cs contains the solution files and has two projects under it: cs/libvoikko is the actual wrapper assembly and cs/libvoikko.tests contains NUnit tests for the wrapper. You can build the whole solution or, if you do not have NUnit available, just cs/libvoikko. To start the build enter appropriate solution or project directory and run the following command:

mdtool build --configuration:Release --target:Build

This will produce the wrapper assembly to cs/libvoikko/bin/Release/libvoikko.dll.

Testing the build results

If you have NUnit available you can run the tests to check that the library works correctly. Tests require that Finnish standard dictionary is installed. Tests can be run from the solution directory with the following command:

nunit-console libvoikko.tests/bin/Release/libvoikko.tests.dll

Documentation

At the moment there is no dedicated API documentation for the .NET interface. Since all our object oriented interfaces are essentially the same you can easily use our Javadoc documentation at http://www.puimula.org/htp/testing/voikko-sdk/java/javadoc/

The only differences between Java and .NET interfaces are those that result from differences between conventions and features of the languages:

  • .NET interface has method names starting with capital letter where Java methods start with lower case letter
  • .NET classes reside in namespace libvoikko (Java uses org.puimula.libvoikko)
  • Settings of the Voikko object are set through .NET properties where Java uses setter methods: voikko.AcceptTitlesInGc = false; vs. voikko.setAcceptTitlesInGc(false);

Sample code

A simple C# Windows Forms application that uses Voikko is available at http://www.puimula.org/htp/testing/voikko-sdk/cs

To use the binary program available in the same location you need to have the native libvoikko dll and a Finnish dictionary available. Both can be placed in the same directory with the executable. The dll can alternatively exist anywhere within the system shared library search path. On Windows the native dll must be named voikko.dll and on Linux or OS X libvoikko.so.