locked
Creating application config files for assemblies and embedding them in the monobundle RRS feed

  • Question

  • User119139 posted

    I'm a bit confused how to get config files embedded into the monobundle. I can create a config file for my application, but it doesn't appear that I can create (or that it will see) a config file created for a referenced assembly. Here's what I need to do:

    I have an assembly that references an external library -- so let's say library1.dll, which is referenced from externalloading.assembly.dll. In the past, prior to creating bundles, when I'd have people use the program, I'd just zip up the program files -- folks would unzip them. In the program files, they'd find an application config file: myapp.exe.config and the externalloading assembly config file: externalloading.assembly.dll.config. If they user wanted to enable the functionality in the external library -- they would open the config file, and set the dllmap values to a path that corresponded to their system.

    I'm trying to recreate this process within my MonoBundle. I create an application config file -- name it after my externalloading assembly -- but no matter what settings I give it - it doesn't get copied into my MonoBundle. Likewise, if I open the bundle, and copy it their directly, the application doesn't appear to be even looking at the file.

    So...I guess I'm looking for some information in how this works when working within the monobundle because it must be different or there must be something I'm missing. Because I can pull all the data out of the bundle, run the mono command line -- and everything works just like I'd expect if I have the exteranlloading.assembly.dll.config file in the folder with the executing assembly.

    Thanks,

    --tr

    Sunday, November 1, 2015 4:10 PM

All replies

  • User13121 posted

    Hi Terry,

    The current process to include a file in MonoBundle requires you to use a custom After Build action to copy the file there (Project Options -> Custom Commands). If you are code-signing you'll also need another custom command after that to re-sign the app.

    We recognize that this is not an ideal situation and I created a bug report to provide a better way to do this.

    Monday, November 2, 2015 8:19 PM
  • User119139 posted

    Ah -- good to know. Can I ask one more question -- I tried dropping the file manually into the MonoBundle and including the full path to the dllmap (which happens to be outside of my application path -- it's referencing a library installed view HomeBrew so it's in the brew Cellar) -- and when I put the file into the Bundle and then run the debugger, I'm getting a dllnot found error. So, I wanted to confirm where I'd put the dllmap as well. In windows, I'd create a config for the individual assembly (so external.assembly.dll.config) rather than putting into the application config file. Would the same process work here -- or by having it in the MonoBundle, is there any other assumptions going on (like the dllmap has to be in a global config file or something).

    I just want to make certain I understand the process.

    Thanks Timothy

    Monday, November 2, 2015 8:27 PM
  • User13121 posted

    You can try launching your app from the command line with:

    MONO_LOG_LEVEL=debug MONO_LOG_MASK="dll,config" Foo.app/Contents/MacOS/Foo
    

    (replacing Foo with the app name). This will output a bunch of information on how it's resolving your libraries and might give you more info to work with on where the problem is.

    Monday, November 2, 2015 8:38 PM
  • User119139 posted

    Thanks -- I'll give it a try this evening and see if that gives me some clues.

    --tr

    Monday, November 2, 2015 8:40 PM
  • User119139 posted

    Ok -- so I gave this a try and looked through the trace log. In the MonoBundle -- have an assembly that is referenced by the application called: Zoom.Net.YazSharp.dll

    This library has headers for both a 32 and 64 bit version of a library. On Linux, Windows (and OSX when not bundled) -- I include a file: Zoom.Net.YazSharp.dll.config in the program directory (i.e., program and assembly are in the same directory, program itself has a .config file, and the referenced assembly has it's own config file)

    Which defines the name of the library on the specific system. I'm installing the library I'll be referencing via brew -- and using the universal installation switch so that I should get a fat version of the dependencies that ought to work regardless of if a user is running a 32 or 64 bit version of the mono runtime.

    Here's how the config file is defined: (fixed by moderator) https://gist.github.com/chamons/da55885d09de8b174b03

    I've included the full path in the target just because I wanted to make sure the specific library was referenced. You'll notice that it's outside of the MonoBundle. In the Mac Application build settings -- I don't enable entitlements, which I'm assuming will allow the program to reference dependencies outside of the MonoBundle (maybe I'm wrong on this -- that would be good to know.

    Anyway -- looking at the log file -- it doesn't appear that the .config file is ever read. While the target is specifically defined -- the file being looked for on the system happens to be: libyaz432 or libyaz464, and these libraries are pretty much only being sought out from within various locations in the MonoBundle folder. So, I'm not sure how I get the runtime to recognize the .config file for the particular assembly and then use the information as defined.

    Any ideas are definitely welcome.

    Thanks,

    --tr

    Wednesday, November 4, 2015 6:29 PM
  • User35201 posted

    Doing some poking around, I found this old post:

    http://forums.xamarin.com/discussion/comment/127991#Comment_127991

    and following it worked for me.

    I made a file called Foo.exe.config (project exe's name Foo.exe) and copied it into MonoBundle. And while running the redirect took.

    Thursday, November 5, 2015 4:23 PM
  • User119139 posted

    I'd seen that too -- and yes, foo.exe.config works fine. What doesn't appear to work is having a config file that's foo.assembly.dll.config -- which has worked fine on Windows via .NET, Linux (via mono) and OSX (when not bundled). And I guess that's kind of my question -- should all references be made in the app.exe.config space -- or is something that should be working -- not.

    Thanks Chris.

    Thursday, November 5, 2015 6:04 PM
  • User35201 posted

    I'm not exactly sure why non-exe config files aren't being read. You can file a bug https://bugzilla.xamarin.com if you desire and we can look into it when we get time.

    I would stick with app.exe.config being the location for all of your redirects, since it currently works. :)

    Thursday, November 5, 2015 6:07 PM