0
votes

I have a simple gtk# mono app running on windows. It works fine on my PC which has Mono, .NET, and GTK installed. But if I give the exe to a friend it obviously doesn't work.

Mono's mkbundle tool doesn't seem to work on windows without an enormous amount of hassle (I've tried). So I've reverted to the quick solution of just including the necessary DLL's with the exe when giving it to a friend.

But I don't know what is required. My guesses so far have been wrong. I tried including everything that mkbundle wanted to embed, but that didn't work. Is there some tool that can tell me what I need?

2

2 Answers

1
votes

Create a new console project (example name InspectRefAssm), paste this inside of it:

using System;
using System.Reflection;

namespace InspectRefAssm
{
    class Program
    {
        static void Main(string[] args)
        {
            if (args.Length < 1 || string.IsNullOrEmpty(args[0]))
            {
                Console.WriteLine("This program requires an argument to the path of the executable.");
                Console.WriteLine("Example:");
                Console.WriteLine(Path.GetFileName(Assembly.GetEntryAssembly().Location) + @" c:\Path\To\Executable.exe");
                Console.ReadKey(true);
                return;
            }

            if (!File.Exists(args[0]))
            {
                Console.WriteLine("File not found.");
                Console.ReadKey(true);
                return;
            }

            Assembly asm = Assembly.LoadFile(args[0]);

            foreach (AssemblyName asmName in asm.GetReferencedAssemblies())
            {
                Console.WriteLine(asmName.FullName);
            }

            Console.ReadKey(true);
        }
    }
}

Compile it, then call it with:

InspectRefAssm.exe "Path\To\YourExecutable.exe"

This uses reflection to determine the libraries referenced by the executable file. If you have multiple files that are part of your executable, you may need to run this for every file, or you can modify it to be recursive, I'll leave that as an exercise for you.

1
votes

If you want to distribute a program made with Gtk#/Mono, then you need your friend to install Gtk# for Windows. Once this is installed, just copy and execute the exe, and you're done.