mkbundle & Assembly.GetEntryAssembly()
Rick Tillery <[email protected]> Mon, 15 May 2017 15:14:42 -0500
| Newsgroups | gmane.comp.gnome.mono.devel |
|---|---|
| Message-ID | <CAAZEOjsyXNNX2EGMDdeizi+1hedZSf2=hhR_6oqTE0m47JfKUg@mail.gmail.com> |
I checked the archives, but didn't see a reference to this issue (within
the last few years).
I have a project with a need to validate the assembly that is its entry
point.
Using Assembly.GetEntryAssembly() works for a stand-alone EXE, both in
Windows and in Linux (launched with "$ mono app.exe") but the path returned
by Assembly.CodeBase is for the EXE when I use mkbundle.
I've distilled the issue down to the following code, but in the project,
the path is used to check for a signed entry assembly. mkbundle is needed
for several unrelated reasons, which would be difficult to address in other
ways.
$ cat assytest.cs
using System.Reflection;
public class Test
{
public static void Main()
{
Assembly thisassy = Assembly.GetEntryAssembly();
System.Console.WriteLine("Assembly Type: " + thisassy.GetType());
System.Console.WriteLine(" CodeBase: " + thisassy.CodeBase);
System.Console.WriteLine(" FullName: " + thisassy.FullName);
System.Console.WriteLine(" Location: " + thisassy.Location);
}
}
$ mcs assytest.cs
Any of these bundles provide the same output:
$ mkbundle -L /usr/lib/mono/4.5 -o assytest-noargs assytest.exe
$ mkbundle -L /usr/lib/mono/4.5 -o assytest-deps --deps assytest.exe
$ mkbundle -L /usr/lib/mono/4.5 -o assytest-static --static assytest.exe
$ mkbundle -L /usr/lib/mono/4.5 -o assytest-staticdeps --static --deps
assytest.exe
$ rm assytest.exe
$ ./assytest-staticdeps
Assembly Type: System.Reflection.MonoAssembly
CodeBase: file:///home/user/*assytest.exe*
FullName: assytest, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
Location: assytest.exe
The EXE itself, launched with mono returns nearly the same thing:
$ mcs assytest.cs
$ mono assytest.exe
Assembly Type: System.Reflection.MonoAssembly
CodeBase: file:///home/user/assytest.exe
FullName: assytest, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
Location: */home/user/*assytest.exe
The problem is that this means the entry assembly being returned is not the
actual entry point, and I don't see a way to determine the assembly that is
the correct entry point.
Any suggestions?
Thanks,
Rick
_______________________________________________
Mono-devel-list mailing list
[email protected]
http://lists.dot.net/mailman/listinfo/mono-devel-list