开发者

Office Excel 2007 Add-in is not reading app.config in Win7 64 bit Office 2010 32 bit machines under deployment

My application works like this, 1. The Office 2007 Excel Add-in reads information from the App.Config file.

2. Uses that information to various purposes within the application.

I have got a strange problem in Win7 64 bit and Office 2010 32 bit/64 bit machines when this add-in is deployed. There is no need to create a new add-in for Office 2010 as your Office 2007 add-in will be compatible there.

The configuration file is not read and there is no information to use and so the application fails subsequently. This happens in deployment scenario alone.

Please refer to the attached sample add-in which is created cl开发者_开发百科osely to my requirement.

1. You need to have a file C:\Test.log before running this project. This will save some information as log.

2. Build the project and build the setup project seperately. The setup file will be available in ${proj_folder}\ExcelAddInSetupProject\Debug.

3. In debug mode things will work fine. On installing the setup file, the configuration file will not be read.

4. Specifically the following codes are not working.

string[] names = ConfigurationManager.AppSettings.GetValues("Name");

if (names != null && names.Length > 0)

{

name = names[0];

}

or

string un = System.Configuration.ConfigurationSettings.AppSettings["Name"];

Can you please let me know why this happens? Is there any fix for this?


The code that use for getting config strings from the app.config is:

string value = ConfigurationManager.AppSettings.Get(keyName);

The only other thing is to make sure that the app.config is in the same project as the adddin but not under the Excel section.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜