On Feb 19, 2013, at 11:20 PM, Chris Tacke <[email protected]> wrote:
> Yes, I've read the warning label, and I know that dynamically loading
> assemblies is somewhat discouraged.
I need to work on how I phrase this. Dynamically loading assemblies is fine, AS
LONG AS said assembly is present at app packaging time. Otherwise, all bets are
off.
> I thought, ok, maybe I can figure out the "path" to the folder from which I'm
> running, and then look for DLLs there and load that way. Ha. After several
> hours of trying to figure out a way to get the path that would work under
> Debug and Release, I came up with nothing but more grey hair.
This is addressed at:
http://docs.xamarin.com/guides/android/advanced_topics/architecture#1-application-packages
TL;DR: in Release builds, assemblies are stored within the .apk; they do not
exist on the file system.
> Sooooo...... any thoughts on how I might get the name of a DLL that I know
> is in my APK, but that I don't "know" the name of at build time (I'm loading
> them and looking for interfaces via reflection to detect their "Adapterness").
I can think of a couple of ways, not necessarily good...
1. Provide a "manifest" with your app which lists which assemblies you can
load, and read said manifest at runtime instead of checking the filesystem.
(In effect, you're still hardcoding the assembly name, you're just hardcoding
it in a config file instead of in source.)
You could also automate this somewhat (generate the manifest at build time
based on filesystem contents of your build machine), but does entail extra
logic.
2. Use a ZIP library (Java.Util.Zip? Ionic.Zip.dll?), open the .apk for your
app (Context.ApplicationInfo.SourceDir), and look for all entries within the
.apk which end in .dll.
Note: One of the new features in Xamarin.Android 4.6 is Bundle assemblies into
Native code, the effect of which is to "mkbundle" the assemblies into a native
library instead of storing them within the .apk as was previously done.
Enabling this option will thus prevent traversing the .apk from finding your
assemblies.
I'd suggest (1), myself.
- Jon
_______________________________________________
Monodroid mailing list
[email protected]
UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid