Reading from app.config

K

Kalpana

Hi all

Is it possible to read from app.config file like you would in the web app or
win app. I tried
System.Configuration.ConfigurationSettings.AppSettings["Administrator"].ToString();
- for one it is an obselete method - but from my intellisense i don't get the
Configuration Manager , but apart from it I get Object set to null .

Any help is greatly appreciated...

Thanks
Kalpana
 
K

Kalyan G Reddy MVP (GGK Tech)

Hello

App.config can be read the same way as web.config file.
which version of VS are you using? if it is VS2005 use
configurationManagerin place of ConfigurationSettings.
Also check whether the Administrator is mentioned in the App.config correctly

Also No need of using ToString();This will throw an error when your function
returns a null value. You should write a condition to execute ToString();
when it is not Null
 
K

Kalpana

Hi Kalyan

Lets say this is what I have in my app.config
<appSettings>
<add key="Administrator" value="administrator"/>
<add key="Password" value="password$"/>
</appSettings>

and this what i am using in form.cs code

string administrator = string.Empty;
string password = string.Empty;
administrator = ConfigurationManager.AppSettings["Administrator"];
password = ConfigurationManager.AppSettings["Password"];

I just get empty string. This is frustrating..... :)

Thanks for your help
Kalpana






Kalyan G Reddy MVP (GGK Tech) said:
Hello

App.config can be read the same way as web.config file.
which version of VS are you using? if it is VS2005 use
configurationManagerin place of ConfigurationSettings.
Also check whether the Administrator is mentioned in the App.config correctly

Also No need of using ToString();This will throw an error when your function
returns a null value. You should write a condition to execute ToString();
when it is not Null
--
Kalyan G Reddy - INFOPATH MVP 2007
http://www.ggktech.com




Kalpana said:
Hi all

Is it possible to read from app.config file like you would in the web app or
win app. I tried
System.Configuration.ConfigurationSettings.AppSettings["Administrator"].ToString();
- for one it is an obselete method - but from my intellisense i don't get the
Configuration Manager , but apart from it I get Object set to null .

Any help is greatly appreciated...

Thanks
Kalpana
 
K

Kalpana

Hi Kalyan

When I upload the XSN template to SharePoint I wonder if it has any
reference to the app.config.exe at runtime. May be it is not seeing this file
at all. Would that be possible you think?

Thanks
Kalpana

Kalpana said:
Hi Kalyan

Lets say this is what I have in my app.config
<appSettings>
<add key="Administrator" value="administrator"/>
<add key="Password" value="password$"/>
</appSettings>

and this what i am using in form.cs code

string administrator = string.Empty;
string password = string.Empty;
administrator = ConfigurationManager.AppSettings["Administrator"];
password = ConfigurationManager.AppSettings["Password"];

I just get empty string. This is frustrating..... :)

Thanks for your help
Kalpana






Kalyan G Reddy MVP (GGK Tech) said:
Hello

App.config can be read the same way as web.config file.
which version of VS are you using? if it is VS2005 use
configurationManagerin place of ConfigurationSettings.
Also check whether the Administrator is mentioned in the App.config correctly

Also No need of using ToString();This will throw an error when your function
returns a null value. You should write a condition to execute ToString();
when it is not Null
--
Kalyan G Reddy - INFOPATH MVP 2007
http://www.ggktech.com




Kalpana said:
Hi all

Is it possible to read from app.config file like you would in the web app or
win app. I tried
System.Configuration.ConfigurationSettings.AppSettings["Administrator"].ToString();
- for one it is an obselete method - but from my intellisense i don't get the
Configuration Manager , but apart from it I get Object set to null .

Any help is greatly appreciated...

Thanks
Kalpana
 
K

Kalyan G Reddy MVP (GGK Tech)

Hello Kalpana

I dont see anything wrong in the code and I dont understand where it is
going wrong. May be some one else can help you out Lets wait and see
Goodluck
--
Kalyan G Reddy - INFOPATH MVP 2007
http://www.ggktech.com




Kalpana said:
Hi Kalyan

Lets say this is what I have in my app.config
<appSettings>
<add key="Administrator" value="administrator"/>
<add key="Password" value="password$"/>
</appSettings>

and this what i am using in form.cs code

string administrator = string.Empty;
string password = string.Empty;
administrator = ConfigurationManager.AppSettings["Administrator"];
password = ConfigurationManager.AppSettings["Password"];

I just get empty string. This is frustrating..... :)

Thanks for your help
Kalpana






Kalyan G Reddy MVP (GGK Tech) said:
Hello

App.config can be read the same way as web.config file.
which version of VS are you using? if it is VS2005 use
configurationManagerin place of ConfigurationSettings.
Also check whether the Administrator is mentioned in the App.config correctly

Also No need of using ToString();This will throw an error when your function
returns a null value. You should write a condition to execute ToString();
when it is not Null
--
Kalyan G Reddy - INFOPATH MVP 2007
http://www.ggktech.com




Kalpana said:
Hi all

Is it possible to read from app.config file like you would in the web app or
win app. I tried
System.Configuration.ConfigurationSettings.AppSettings["Administrator"].ToString();
- for one it is an obselete method - but from my intellisense i don't get the
Configuration Manager , but apart from it I get Object set to null .

Any help is greatly appreciated...

Thanks
Kalpana
 
K

Kalpana

Hi Kalyan

When I upload the XSN template to SharePoint I wonder if it has any
reference to the app.config.exe at runtime. May be it is not seeing this file
at all. Would that be possible you think?
I am not sure if you saw this

May be explaining the steps would will make things clear

From My Visual Studio Project I click on Manifest.xsf and then Design tasks,
Publish form
Create MSI
Run the msi
From SharePoint Manage Form Templates I pick the xsn and activate the template

I don't see where app.config is transferred over. Could this be the problem
you think.

Thanks
Kalpana

Kalyan G Reddy MVP (GGK Tech) said:
Hello Kalpana

I dont see anything wrong in the code and I dont understand where it is
going wrong. May be some one else can help you out Lets wait and see
Goodluck
--
Kalyan G Reddy - INFOPATH MVP 2007
http://www.ggktech.com




Kalpana said:
Hi Kalyan

Lets say this is what I have in my app.config
<appSettings>
<add key="Administrator" value="administrator"/>
<add key="Password" value="password$"/>
</appSettings>

and this what i am using in form.cs code

string administrator = string.Empty;
string password = string.Empty;
administrator = ConfigurationManager.AppSettings["Administrator"];
password = ConfigurationManager.AppSettings["Password"];

I just get empty string. This is frustrating..... :)

Thanks for your help
Kalpana






Kalyan G Reddy MVP (GGK Tech) said:
Hello

App.config can be read the same way as web.config file.
which version of VS are you using? if it is VS2005 use
configurationManagerin place of ConfigurationSettings.
Also check whether the Administrator is mentioned in the App.config correctly

Also No need of using ToString();This will throw an error when your function
returns a null value. You should write a condition to execute ToString();
when it is not Null
--
Kalyan G Reddy - INFOPATH MVP 2007
http://www.ggktech.com




:

Hi all

Is it possible to read from app.config file like you would in the web app or
win app. I tried
System.Configuration.ConfigurationSettings.AppSettings["Administrator"].ToString();
- for one it is an obselete method - but from my intellisense i don't get the
Configuration Manager , but apart from it I get Object set to null .

Any help is greatly appreciated...

Thanks
Kalpana
 
K

Kalyan G Reddy MVP (GGK Tech)

Hello

Where is your App.Config located and Do you have any webservice as
Dataconnection. I dont think Only Infopath without webservice would access
the App.config.

--
Kalyan G Reddy - INFOPATH MVP 2007
http://www.ggktech.com




Kalpana said:
Hi Kalyan

When I upload the XSN template to SharePoint I wonder if it has any
reference to the app.config.exe at runtime. May be it is not seeing this file
at all. Would that be possible you think?
I am not sure if you saw this

May be explaining the steps would will make things clear

From My Visual Studio Project I click on Manifest.xsf and then Design tasks,
Publish form
Create MSI
Run the msi
From SharePoint Manage Form Templates I pick the xsn and activate the template

I don't see where app.config is transferred over. Could this be the problem
you think.

Thanks
Kalpana

Kalyan G Reddy MVP (GGK Tech) said:
Hello Kalpana

I dont see anything wrong in the code and I dont understand where it is
going wrong. May be some one else can help you out Lets wait and see
Goodluck
--
Kalyan G Reddy - INFOPATH MVP 2007
http://www.ggktech.com




Kalpana said:
Hi Kalyan

Lets say this is what I have in my app.config
<appSettings>
<add key="Administrator" value="administrator"/>
<add key="Password" value="password$"/>
</appSettings>

and this what i am using in form.cs code

string administrator = string.Empty;
string password = string.Empty;
administrator = ConfigurationManager.AppSettings["Administrator"];
password = ConfigurationManager.AppSettings["Password"];

I just get empty string. This is frustrating..... :)

Thanks for your help
Kalpana






:

Hello

App.config can be read the same way as web.config file.
which version of VS are you using? if it is VS2005 use
configurationManagerin place of ConfigurationSettings.
Also check whether the Administrator is mentioned in the App.config correctly

Also No need of using ToString();This will throw an error when your function
returns a null value. You should write a condition to execute ToString();
when it is not Null
--
Kalyan G Reddy - INFOPATH MVP 2007
http://www.ggktech.com




:

Hi all

Is it possible to read from app.config file like you would in the web app or
win app. I tried
System.Configuration.ConfigurationSettings.AppSettings["Administrator"].ToString();
- for one it is an obselete method - but from my intellisense i don't get the
Configuration Manager , but apart from it I get Object set to null .

Any help is greatly appreciated...

Thanks
Kalpana
 
K

Kalpana

Tha app.config is part of the project

Kalyan G Reddy MVP (GGK Tech) said:
Hello

Where is your App.Config located and Do you have any webservice as
Dataconnection. I dont think Only Infopath without webservice would access
the App.config.

--
Kalyan G Reddy - INFOPATH MVP 2007
http://www.ggktech.com




Kalpana said:
Hi Kalyan

When I upload the XSN template to SharePoint I wonder if it has any
reference to the app.config.exe at runtime. May be it is not seeing this file
at all. Would that be possible you think?
I am not sure if you saw this

May be explaining the steps would will make things clear

From My Visual Studio Project I click on Manifest.xsf and then Design tasks,
Publish form
Create MSI
Run the msi
From SharePoint Manage Form Templates I pick the xsn and activate the template

I don't see where app.config is transferred over. Could this be the problem
you think.

Thanks
Kalpana

Kalyan G Reddy MVP (GGK Tech) said:
Hello Kalpana

I dont see anything wrong in the code and I dont understand where it is
going wrong. May be some one else can help you out Lets wait and see
Goodluck
--
Kalyan G Reddy - INFOPATH MVP 2007
http://www.ggktech.com




:

Hi Kalyan

Lets say this is what I have in my app.config
<appSettings>
<add key="Administrator" value="administrator"/>
<add key="Password" value="password$"/>
</appSettings>

and this what i am using in form.cs code

string administrator = string.Empty;
string password = string.Empty;
administrator = ConfigurationManager.AppSettings["Administrator"];
password = ConfigurationManager.AppSettings["Password"];

I just get empty string. This is frustrating..... :)

Thanks for your help
Kalpana






:

Hello

App.config can be read the same way as web.config file.
which version of VS are you using? if it is VS2005 use
configurationManagerin place of ConfigurationSettings.
Also check whether the Administrator is mentioned in the App.config correctly

Also No need of using ToString();This will throw an error when your function
returns a null value. You should write a condition to execute ToString();
when it is not Null
--
Kalyan G Reddy - INFOPATH MVP 2007
http://www.ggktech.com




:

Hi all

Is it possible to read from app.config file like you would in the web app or
win app. I tried
System.Configuration.ConfigurationSettings.AppSettings["Administrator"].ToString();
- for one it is an obselete method - but from my intellisense i don't get the
Configuration Manager , but apart from it I get Object set to null .

Any help is greatly appreciated...

Thanks
Kalpana
 
K

K.Ramana Reddy(GGK Tech)

InfoPath solutions will not have app.config at all. Any kind of configuration
you want to have should be in a resource file (it can be in a shared location
or in the xsn itself).

--
k.Ramana Reddy
http://www.GGKtech.com


Kalpana said:
Tha app.config is part of the project

Kalyan G Reddy MVP (GGK Tech) said:
Hello

Where is your App.Config located and Do you have any webservice as
Dataconnection. I dont think Only Infopath without webservice would access
the App.config.

--
Kalyan G Reddy - INFOPATH MVP 2007
http://www.ggktech.com




Kalpana said:
Hi Kalyan

When I upload the XSN template to SharePoint I wonder if it has any
reference to the app.config.exe at runtime. May be it is not seeing this file
at all. Would that be possible you think?
I am not sure if you saw this

May be explaining the steps would will make things clear

From My Visual Studio Project I click on Manifest.xsf and then Design tasks,
Publish form
Create MSI
Run the msi
From SharePoint Manage Form Templates I pick the xsn and activate the template

I don't see where app.config is transferred over. Could this be the problem
you think.

Thanks
Kalpana

:

Hello Kalpana

I dont see anything wrong in the code and I dont understand where it is
going wrong. May be some one else can help you out Lets wait and see
Goodluck
--
Kalyan G Reddy - INFOPATH MVP 2007
http://www.ggktech.com




:

Hi Kalyan

Lets say this is what I have in my app.config
<appSettings>
<add key="Administrator" value="administrator"/>
<add key="Password" value="password$"/>
</appSettings>

and this what i am using in form.cs code

string administrator = string.Empty;
string password = string.Empty;
administrator = ConfigurationManager.AppSettings["Administrator"];
password = ConfigurationManager.AppSettings["Password"];

I just get empty string. This is frustrating..... :)

Thanks for your help
Kalpana






:

Hello

App.config can be read the same way as web.config file.
which version of VS are you using? if it is VS2005 use
configurationManagerin place of ConfigurationSettings.
Also check whether the Administrator is mentioned in the App.config correctly

Also No need of using ToString();This will throw an error when your function
returns a null value. You should write a condition to execute ToString();
when it is not Null
--
Kalyan G Reddy - INFOPATH MVP 2007
http://www.ggktech.com




:

Hi all

Is it possible to read from app.config file like you would in the web app or
win app. I tried
System.Configuration.ConfigurationSettings.AppSettings["Administrator"].ToString();
- for one it is an obselete method - but from my intellisense i don't get the
Configuration Manager , but apart from it I get Object set to null .

Any help is greatly appreciated...

Thanks
Kalpana
 
K

Kalpana

Hi Ramana

Can you walk through the steps for me please?

Thanks
Kalpana

K.Ramana Reddy(GGK Tech) said:
InfoPath solutions will not have app.config at all. Any kind of configuration
you want to have should be in a resource file (it can be in a shared location
or in the xsn itself).

--
k.Ramana Reddy
http://www.GGKtech.com


Kalpana said:
Tha app.config is part of the project

Kalyan G Reddy MVP (GGK Tech) said:
Hello

Where is your App.Config located and Do you have any webservice as
Dataconnection. I dont think Only Infopath without webservice would access
the App.config.

--
Kalyan G Reddy - INFOPATH MVP 2007
http://www.ggktech.com




:

Hi Kalyan

When I upload the XSN template to SharePoint I wonder if it has any
reference to the app.config.exe at runtime. May be it is not seeing this file
at all. Would that be possible you think?
I am not sure if you saw this

May be explaining the steps would will make things clear

From My Visual Studio Project I click on Manifest.xsf and then Design tasks,
Publish form
Create MSI
Run the msi
From SharePoint Manage Form Templates I pick the xsn and activate the template

I don't see where app.config is transferred over. Could this be the problem
you think.

Thanks
Kalpana

:

Hello Kalpana

I dont see anything wrong in the code and I dont understand where it is
going wrong. May be some one else can help you out Lets wait and see
Goodluck
--
Kalyan G Reddy - INFOPATH MVP 2007
http://www.ggktech.com




:

Hi Kalyan

Lets say this is what I have in my app.config
<appSettings>
<add key="Administrator" value="administrator"/>
<add key="Password" value="password$"/>
</appSettings>

and this what i am using in form.cs code

string administrator = string.Empty;
string password = string.Empty;
administrator = ConfigurationManager.AppSettings["Administrator"];
password = ConfigurationManager.AppSettings["Password"];

I just get empty string. This is frustrating..... :)

Thanks for your help
Kalpana






:

Hello

App.config can be read the same way as web.config file.
which version of VS are you using? if it is VS2005 use
configurationManagerin place of ConfigurationSettings.
Also check whether the Administrator is mentioned in the App.config correctly

Also No need of using ToString();This will throw an error when your function
returns a null value. You should write a condition to execute ToString();
when it is not Null
--
Kalyan G Reddy - INFOPATH MVP 2007
http://www.ggktech.com




:

Hi all

Is it possible to read from app.config file like you would in the web app or
win app. I tried
System.Configuration.ConfigurationSettings.AppSettings["Administrator"].ToString();
- for one it is an obselete method - but from my intellisense i don't get the
Configuration Manager , but apart from it I get Object set to null .

Any help is greatly appreciated...

Thanks
Kalpana
 
K

Kalyan G Reddy MVP (GGK Tech)

Hello

Are you using any webservice? What are you trying to achieve by using
App.Config and where did you place it in the Project (Like resource files
etc...)

--
Kalyan G Reddy - INFOPATH MVP 2007
http://www.ggktech.com




Kalpana said:
Tha app.config is part of the project

Kalyan G Reddy MVP (GGK Tech) said:
Hello

Where is your App.Config located and Do you have any webservice as
Dataconnection. I dont think Only Infopath without webservice would access
the App.config.

--
Kalyan G Reddy - INFOPATH MVP 2007
http://www.ggktech.com




Kalpana said:
Hi Kalyan

When I upload the XSN template to SharePoint I wonder if it has any
reference to the app.config.exe at runtime. May be it is not seeing this file
at all. Would that be possible you think?
I am not sure if you saw this

May be explaining the steps would will make things clear

From My Visual Studio Project I click on Manifest.xsf and then Design tasks,
Publish form
Create MSI
Run the msi
From SharePoint Manage Form Templates I pick the xsn and activate the template

I don't see where app.config is transferred over. Could this be the problem
you think.

Thanks
Kalpana

:

Hello Kalpana

I dont see anything wrong in the code and I dont understand where it is
going wrong. May be some one else can help you out Lets wait and see
Goodluck
--
Kalyan G Reddy - INFOPATH MVP 2007
http://www.ggktech.com




:

Hi Kalyan

Lets say this is what I have in my app.config
<appSettings>
<add key="Administrator" value="administrator"/>
<add key="Password" value="password$"/>
</appSettings>

and this what i am using in form.cs code

string administrator = string.Empty;
string password = string.Empty;
administrator = ConfigurationManager.AppSettings["Administrator"];
password = ConfigurationManager.AppSettings["Password"];

I just get empty string. This is frustrating..... :)

Thanks for your help
Kalpana






:

Hello

App.config can be read the same way as web.config file.
which version of VS are you using? if it is VS2005 use
configurationManagerin place of ConfigurationSettings.
Also check whether the Administrator is mentioned in the App.config correctly

Also No need of using ToString();This will throw an error when your function
returns a null value. You should write a condition to execute ToString();
when it is not Null
--
Kalyan G Reddy - INFOPATH MVP 2007
http://www.ggktech.com




:

Hi all

Is it possible to read from app.config file like you would in the web app or
win app. I tried
System.Configuration.ConfigurationSettings.AppSettings["Administrator"].ToString();
- for one it is an obselete method - but from my intellisense i don't get the
Configuration Manager , but apart from it I get Object set to null .

Any help is greatly appreciated...

Thanks
Kalpana
 
D

David Dean

If you're publishing a browser-enabled form template, you won't be able to
use an app.config file for configuration entries. This is due to how the form
template assembly gets deployed by Forms Services.

An alternative approach that works with Forms Services is to create an XML
file that contains your settings, then add a secondary data source to your
form template that loads the XML file. You can then access the values from
rules or from code in the form template.

--
David Dean
Sr. Member Technical Staff
Insource Technology Corp.


Kalpana said:
Hi Kalyan

When I upload the XSN template to SharePoint I wonder if it has any
reference to the app.config.exe at runtime. May be it is not seeing this file
at all. Would that be possible you think?
I am not sure if you saw this

May be explaining the steps would will make things clear

From My Visual Studio Project I click on Manifest.xsf and then Design tasks,
Publish form
Create MSI
Run the msi
From SharePoint Manage Form Templates I pick the xsn and activate the template

I don't see where app.config is transferred over. Could this be the problem
you think.

Thanks
Kalpana

Kalyan G Reddy MVP (GGK Tech) said:
Hello Kalpana

I dont see anything wrong in the code and I dont understand where it is
going wrong. May be some one else can help you out Lets wait and see
Goodluck
--
Kalyan G Reddy - INFOPATH MVP 2007
http://www.ggktech.com




Kalpana said:
Hi Kalyan

Lets say this is what I have in my app.config
<appSettings>
<add key="Administrator" value="administrator"/>
<add key="Password" value="password$"/>
</appSettings>

and this what i am using in form.cs code

string administrator = string.Empty;
string password = string.Empty;
administrator = ConfigurationManager.AppSettings["Administrator"];
password = ConfigurationManager.AppSettings["Password"];

I just get empty string. This is frustrating..... :)

Thanks for your help
Kalpana






:

Hello

App.config can be read the same way as web.config file.
which version of VS are you using? if it is VS2005 use
configurationManagerin place of ConfigurationSettings.
Also check whether the Administrator is mentioned in the App.config correctly

Also No need of using ToString();This will throw an error when your function
returns a null value. You should write a condition to execute ToString();
when it is not Null
--
Kalyan G Reddy - INFOPATH MVP 2007
http://www.ggktech.com




:

Hi all

Is it possible to read from app.config file like you would in the web app or
win app. I tried
System.Configuration.ConfigurationSettings.AppSettings["Administrator"].ToString();
- for one it is an obselete method - but from my intellisense i don't get the
Configuration Manager , but apart from it I get Object set to null .

Any help is greatly appreciated...

Thanks
Kalpana
 
S

S.Y.M. Wong-A-Ton

Yes, it is possible, but it won't work as you would expect it to work, that
is, you cannot just add an app.config file to your InfoPath project. You
basically use the same code as you're currently using; the only thing is that
for the forms that run in the InfoPath client application, you need to create
an app.config where the client application is located. Note: All forms that
run on the client will share this app.config; you cannot configure forms
independently by using this method. For forms that run in the browser, you
must add the settings to the web.config of the SharePoint web application the
forms are located on. Again, all forms will share the same settings for the
same SharePoint web application. This article might clear things up a bit:
http://support.microsoft.com/kb/555963
 

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