Unresolved assembly reference

- Posted in Coding by

Sometimes you'll get “Unresolved assembly reference not allowed” when attempting to use ILMerge. To avoid this, specify the full path to the framework you're targeting, like this:

ilmerge /targetplatform:v4,"C:WindowsMicrosoft.NETFramework64v4.0.30319" /out:merged.exe myprogram.exe mylib1.dll mylib2.dll

Get full path of executing assembly

- Posted in Coding by

C# code to get the full path of the executing assembly:

<script src="https://gist.github.com/kyrathasoft/825c2c277bdaed4d300880415f72ab5b.js"></script>

then there's also this:

<script src="https://gist.github.com/kyrathasoft/4f4f1d6639c6faff0b2e4c77e60ede87.js"></script>

using System;
using System.Reflection; //required for Assembly namespace
using System.IO; //required for Path namespace

namespace HelloWorld {
class Hello {

    static void Main(string[] args){
        Console.WriteLine("n Now executing: {0}", ExecutingAssemblyPath());
        Console.Write("n Press any key to exit... ");
        Console.ReadKey();
        Console.WriteLine();
    }

    public static string ExecutingAssemblyPath(){
    string path = AppDomain.CurrentDomain.BaseDirectory;
    string fname = Assembly.GetEntryAssembly().GetName().Name;
    path += fname;
    if(File.Exists(fname + ".exe")){ path += ".exe"; } else {path += ".dll"; }
        return path;
    }    

  }
}