Rigor69 - 2014-07-23

Hi.

I have a project where i run CoDeSys via the COM interface to create projects automatically.
It works for me mostly, but i have a strange problem.
The instance of CoDeSys that loads when i start the application is never unloaded from memory when my application exits, thus i end up with a new CoDeSys instance in the processes area of the PC for every time i run the program.
I have examined your example very closely, but its in VB, and does not give any clue to this.

My environment:
Visual studio 2010
C# Language
using reference : Interop.CoDeSys.dll

declaration at the top of my class:
CoDeSys.CCoDeSys cs;

Inside my "generate" function:
cs = new CoDeSys.CCoDeSys();

My exit function:

    private void exit()
    {
        System.Runtime.InteropServices.Marshal.ReleaseComObject(cs);
        cs = null;
        GC.Collect();
        GC.WaitForPendingFinalizers();
        System.Windows.Forms.Application.Exit();
        //but cs still remain in memory....
    }

How to properly terminate codesys so that it unloads?

Thanks...