app.config with infopath?

G

G. Kumar

Hi, is it possible to have an app.config file with an infopath visual studio .net project? I tried adding an app.config file to my project and setting it to this:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="some key" value="some value" />
</appSettings>
</configuration>

Then I tried accessing the information in there through code like this:

AppSettingsReader configReader = new AppSettingsReader();
return (string)configReader.GetValue("some key",typeof(string));

This is in an onclick event for a button. When I preview the form and click the button, I get an error that's something like "key 'some key' does not exist in the appSettings section of the configuration file". Am I missing something general for app.config files? I seemed to do exactly what examples on the web did but I can't figure out this error. I thought maybe Infopath doesn't support using app.config files or something. Does anyone have any thoughts on this? Thanks!
 
M

Matthew Blain \(Serriform\)

You're best off not using app.config files with any Office solution, but
rather adding your own configuration to the solution itself. For more
information, there have been posts in the past in this newsgroup on the
topic which you can search for.

--Matthew Blain
http://tips.serriform.com/

G. Kumar said:
Hi, is it possible to have an app.config file with an infopath visual
studio .net project? I tried adding an app.config file to my project and
setting it to this:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="some key" value="some value" />
</appSettings>
</configuration>

Then I tried accessing the information in there through code like this:

AppSettingsReader configReader = new AppSettingsReader();
return (string)configReader.GetValue("some key",typeof(string));

This is in an onclick event for a button. When I preview the form and
click the button, I get an error that's something like "key 'some key' does
not exist in the appSettings section of the configuration file". Am I
missing something general for app.config files? I seemed to do exactly what
examples on the web did but I can't figure out this error. I thought maybe
Infopath doesn't support using app.config files or something. Does anyone
have any thoughts on this? Thanks!
 
G

G. Kumar

What do you mean? What is your own configuration to the solution itself? I want some file that is easily changeable (without having to change code) that comes along with the Infopath form or something like that. Is this possible?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top