Using app.config from an XLL add-in

Add-in Express™ Support Service
That's what is more important than anything else

Using app.config from an XLL add-in
 
Yuri Astrakhan




Posts: 53
Joined: 2006-05-19
It appears that the XLL add-in's appName.dll.config is not automatically loaded by my add-in. The read-only SetupInformation AppDomain class has correct application base directory (my project), but uses "C:\Program Files\Microsoft Office\Office12\EXCEL.EXE.config" for the config file. Since a large number of modules use app.config to get its configuration, is it possible to make the appName.dll.config behave like the real app.config?

Thanks!
Posted 01 Feb, 2008 02:55:37 Top
Sergey Grischenko


Add-in Express team


Posts: 7233
Joined: 2004-07-05
Hi Yuri.

Please download a new loader here:
http://www.add-in-express.com/projects/adxloader.zip

It works with the add-in config file. You just need to set the name of the config in the adxloader.dll.manifest file. Please see the example in the archive. Don't forget to re-register the project.
If you use the config for the XLL add-in, you also need to rename the adxloader.dll to adxloader.<assembly name>.dll in the Loader subdirectory of the add-in project.
Posted 01 Feb, 2008 06:30:07 Top
Yuri Astrakhan




Posts: 53
Joined: 2006-05-19
Hi Sergey, it works beautifully! Thank you very much! Will you release this new loader as part of the standard package in the next version?
Posted 01 Feb, 2008 10:39:04 Top
Yuri Astrakhan




Posts: 53
Joined: 2006-05-19
Please note that the setup project does not automatically include proj.dll.config. The best way I found (that would both allow Visual Studio to modify it with wizards and not be dependent on which build configuration you choose to build) is to add the app.config file itself to the setup project and specify a different TargetName property to "proj.dll.config" name.

I think it would help everyone if the new project wizard automatically adds app.config and the custom file inclusion in the setup.
Posted 01 Feb, 2008 16:55:18 Top
Sergey Grischenko


Add-in Express team


Posts: 7233
Joined: 2004-07-05
Hi Yuri.

Thank you for the suggestion.
We will add the new loader in Add-in Express v4.1.
Posted 04 Feb, 2008 07:02:06 Top
Yuri Astrakhan




Posts: 53
Joined: 2006-05-19
Sergey, another, unexpected problem related to the config files: if I try to deploy a project containing app.config file using clickonce, IIS will not allow me to download .config file due to security restrictions. Apparently there are some ways clickonce handles it, but I haven't yet been able to work around them. Please let me know if you know anything about it.

Thanks!
Posted 06 Feb, 2008 04:35:42 Top
Sergey Grischenko


Add-in Express team


Posts: 7233
Joined: 2004-07-05
Hi Yuri.

I think you need to rename the app.config file to app.config.deploy.
Then you need to rename it again in the 'OnClickOnceAction' event handler of the ClickOnce module while the add-in is installed on the target PC.
Posted 06 Feb, 2008 07:18:16 Top
Yuri Astrakhan




Posts: 53
Joined: 2006-05-19
Hi Sergey, thanks for the suggestion, but I couldn't get it to work -- I added the clickonce module to the XLL project, added the event, but the event never got called.

I found an easier workaround that does not require any renaming: I simply added a web.config file to my project and set it to be copied automatically to the output (don't forget to fix all opening and closing angular brackets)

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <system.web>
    <compilation defaultLanguage="c#" />
    <httpHandlers>
      <clear/>
      <add path="*" verb="*" type="System.Web.StaticFileHandler" validate="false"/>
    </httpHandlers>
  </system.web>
</configuration>


It works fine for intraweb scenarios, but might be a security threat in public -- need to review.
Posted 07 Feb, 2008 00:39:48 Top
Sergey Grischenko


Add-in Express team


Posts: 7233
Joined: 2004-07-05
Hi Yuri.

Ok, I will try to fix the issue in the next Add-in Express version.
Posted 07 Feb, 2008 08:30:28 Top