# Controlling Micro-Manager 2.0 with C# and IKVM

**URL:** <https://forum.microlist.org/t/controlling-micro-manager-2-0-with-c-and-ikvm/2587>\
**Category:** Software\
**Tags:** micro-manager\
**Created:** [June 30, 2024, 4:33pm UTC](https://forum.microlist.org/t/controlling-micro-manager-2-0-with-c-and-ikvm/2587 "2024-06-30T16:33:47Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![BiologyTools](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.microlist.org/biologytools/32/1217_2.png) [@BiologyTools](https://forum.microlist.org/u/BiologyTools)\
**Post date:** [June 30, 2024, 4:33pm UTC](https://forum.microlist.org/t/controlling-micro-manager-2-0-with-c-and-ikvm/2587/1 "2024-06-30T16:33:47Z")

</div>

Now that IKVM 8.9.0 pre-release supports AWT gui elements one can control Micro-Manager with C#. Below is an example code which starts Micro-Manager by creating a MMStudio instance. I’ve made an example C# project on [Github](https://github.com/BiologyTools/MMTest) for those that are interested.

```auto
extern alias mmc;
using mmc::org.micromanager.@internal;
using System;

namespace MMTest
{
    public partial class Form1 : Form
    {
        public Form1(string[] args)
        {
            InitializeComponent();
            Directory.SetCurrentDirectory("C:/Program Files/Micro-Manager-2.0/");
            java.lang.System.setProperty("force.annotation.index", "true");
            // Set the library path (adjust the path as needed)
            java.lang.System.setProperty("org.micromanager.corej.path", "C:/Program Files/Micro-Manager-2.0");
            try
            {
                MMStudio.main(args);
                MMStudio ms = MMStudio.getInstance();
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
    }
}

```

![image](https://us1.discourse-cdn.com/flex020/uploads/microlist/original/2X/5/5f14650e33957eabc28626dbd15bc42a8f28b87d.png)
