Using Log4Net with Excel-DNA

Feb 4, 2014 at 9:20 PM
In my add-in, I've used Log4Net, and it seems to work pretty well. However, I don't really know where to put the config file, or how to have my Add-in locate it.

An Excel-DNA project does not have an app.config, so that's out.

The only solid way I've come up with is to hardcode the config path in my add-in.

Are there any better ideas?
Coordinator
Feb 5, 2014 at 8:04 AM
Hi Grant,

You make a .config file file for your add-in by calling it XXXX.xll.config, and placing it next to your .xll file. (If you're using the ExcelDnaPack packing, it will be put into the packed the .xll automatically, if it is found next to the .xll.

Excel-DNA will load the .xll.config file as the configuration file for the add-in's AppDomain, and Log4Net will find it that way.

-Govert
Feb 6, 2014 at 11:07 PM
Thanks, that works.

Is there a built-in way to make VS copy an App.config to be named XXXX-AddIn.xll.config instead of XXXX.dll.config?

Of course, I can do this with a post-build step, but I thought it might be worth asking. Or I could just include the file under that name to begin with, but I was wondering if I could stick to the usual VS convention.
Coordinator
Feb 7, 2014 at 9:15 AM
Hi Grant,

I don't know of a way to interfere with the built-in "App.Config" copy. Maybe if one made a special Build extension....

I'd recommend just putting it your project in under the correct name, and marking it as" Copy to Output Directory".

-Govert
Feb 7, 2014 at 2:25 PM
I kind of expected that. Thanks for confirming.