Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Office Add-in project, dll and app.config file problems

I have a library project that I created and have used in about three projects so far. A WPF project, a Windows Forms project and a web app project. The dll uses an App.Config file for various keys common to the office such as the path to the networked storage drive. So now I have been asked to create a plug in for MS Office 2010 Excel and Access respectively.

Now I have previously run into the situation where the library project will use the config file for its calling project so I had to add the keys into that project's config file so I figured I would be doing the same thing with this project. I come to start fiddling around with it to see how I can get Office apps to call the dll methods and immediately see that it is not finding anything from the App.Config files.

After looking around I see that an Office Add-in project is really just a project implementing the IDTExtensibility2 interface and registering itself as a COM dll. So now I have a situation where I have a dll with a dependent dll and neither of them can find anything in a config file. So where would I put the config file in this case? I have tried putting it in the Office 14 folder with Excel.exe as well as putting it in the same folder as the Excel Worksheet that makes use of the Add-in but to no avail. Any ideas are greatly appreciated. Thanks!

like image 759
Bugget Avatar asked Oct 23 '22 21:10

Bugget


1 Answers

OK so just to answer this question as I did eventually find it through trial and error. In the case that you are trying to use a config file for an office add-in project that is referencing a dll project, the config file used will still be that of the calling exe. That is to say, the dll project that is called by the add-in project will be looking for keys stored in MSACCESS.EXE.config and EXCEL.EXE.config respectively. The config file used just keeps going up the chain of dlls until it finds the actual calling exe config file.

like image 62
Bugget Avatar answered Nov 03 '22 01:11

Bugget