Nigel, I tried to run your example, t1.cs, with MS Visual Studio 2008, and encountered an error. Stripping the code off I detected that the error happens in the destructor.
The final code is the following: ------------------------------------------------------------------------ using System; using System.Runtime.InteropServices; unsafe class GLPK { void* lp; const string glpkLibrary = "glpk_4_34.dll"; [DllImport(glpkLibrary, SetLastError = true)] static extern void* glp_create_prob(); public GLPK() { Console.WriteLine("Enter constructor"); lp = glp_create_prob(); Console.WriteLine("Exit constructor"); } [DllImport(glpkLibrary, SetLastError = true)] static extern void glp_delete_prob(void* lp); ~GLPK() { Console.WriteLine("Enter destructor"); glp_delete_prob(lp); Console.WriteLine("Exit destructor"); } } class test { public static void Main() { Console.WriteLine("Enter Main"); GLPK lp = new GLPK(); Console.WriteLine("Exit Main"); } } ------------------------------------------------------------------------ The output is the following: Enter Main Enter constructor Exit constructor Exit Main Enter destructor xfree: memory allocation error Error detected in file ..\src\glplib07.c at line 147 Obviously there is something elementary wrong in the call to glp_delete_prob, because removing the call causes the error to disappear. I am not a C# programmer. May be you could tell me what is wrong? Thanks, Andrew Makhorin _______________________________________________ Help-glpk mailing list Help-glpk@gnu.org http://lists.gnu.org/mailman/listinfo/help-glpk