[Mono-dev] How to determine the executable directory in a mkbundle-packaged app?

Deniska DDFROW at gmail.com
Tue Nov 15 01:13:35 EST 2011


Hi,

I'm trying to run the app on Ubuntu 11.10 + mono 2.10.5. The issue is that I
can not find a way to determine the directory where the executable file is
placed during runtime if the app has been packed using mkbundle.

Code:
            Console.WriteLine("Env.CurrentDirectory: " +
Environment.CurrentDirectory);
            Console.WriteLine("Env.CommandLine: " +
Environment.CommandLine);
            Console.WriteLine("Assembly.Location: " +
Assembly.GetEntryAssembly().Location);
            Console.WriteLine("UnixDirInfo: " +
Mono.Unix.UnixDirectoryInfo.GetCurrentDirectory());

Compiled application: TestApp.exe
mkbundle packaged: TestApp 
Command: mkbundle --deps -o TestApp TestApp.exe

Files location:
/rootdir/subdir/TestApp.exe
/rootdir/subdir/TestApp

How to reproduce:
cd /rootdir/subdir

mono TestApp.exe
> Env.CurrentDirectory: /rootdir/subdir
> Env.CommandLine: /rootdir/subdir/TestApp.exe
> Assembly.Location: /rootdir/subdir/TestApp.exe
> UnixDirInfo: /rootdir/subdir
 - everything fine

./TestApp
> Env.CurrentDirectory: /rootdir/subdir
> Env.CommandLine: /rootdir/subdir/TestApp.exe
> Assembly.Location: TestApp.exe
> UnixDirInfo: /rootdir/subdir
 - everything is fine except for Assembly.Location

cd /rootdir/ (cwd is rootdir now)

mono /rootdir/subdir/TestApp.exe
> Env.CurrentDirectory: /rootdir
> Env.CommandLine: /rootdir/subdir/TestApp.exe
> Assembly.Location: /rootdir/subdir/TestApp.exe
> UnixDirInfo: /rootdir
 - everything as expected, I still can use Env.CommandLine or
Assembly.Location

./rootdir/subdir/TestApp
> Env.CurrentDirectory: /rootdir
> Env.CommandLine: /rootdir/TestApp.exe
> Assembly.Location: TestApp.exe
> UnixDirInfo: /rootdir
 - both Env.CommandLine and Assembly.Location are wrong.

So the question is: how can I determine the _real_ location of a
mkbundle-packaged app during runtime? Is there are a way? If no - why?

Thanks in advance.

--
View this message in context: http://mono.1490590.n4.nabble.com/How-to-determine-the-executable-directory-in-a-mkbundle-packaged-app-tp4042049p4042049.html
Sent from the Mono - Dev mailing list archive at Nabble.com.


More information about the Mono-devel-list mailing list