Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / General MS InfoPath Questions / July 2004

Tip: Looking for answers? Try searching our database.

Is it possible to read from a .config-file in InfoPath SP1?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
StefanO-nl - 12 Jul 2004 11:12 GMT
In a Web- or Windows-application you use ConfigurationSettings.AppSettings to read from a .config-file. I'd like to do the same in the FormCode.cs-file, but it seems this doesn't work. I've tried to name the file MyForm.xsn.config (where MyForm is the name of the InfoPath C#-project).

Is there a way to use the standard xml-configfile or should I write my own configfile handler?
Greg Collins [MVP] - 12 Jul 2004 14:40 GMT
If you are using InfoPath SP-1, you just create your XML config file and then add it as a data connection. Then you can access it as a secondary DOM. It will be read/write during the life of the form, but will not be saved unless you specifically force it to be saved by writing code to save it.

If you are using V1, you would add it as a resource file, and then write your own code to load and parse it.

Signature

Greg Collins [InfoPath MVP]
Please visit: http://www.InfoPathDev.com

In a Web- or Windows-application you use ConfigurationSettings.AppSettings to read from a .config-file. I'd like to do the same in the FormCode.cs-file, but it seems this doesn't work. I've tried to name the file MyForm.xsn.config (where MyForm is the name of the InfoPath C#-project).

Is there a way to use the standard xml-configfile or should I write my own configfile handler?
Andrew Ma [MSFT] - 13 Jul 2004 01:40 GMT
Have you tried naming it INFOPATH.EXE.CONFIG.
I'm not familiar with how Windows apps handle it, but as far as I know, this
is how it is supposed to work.
Config files are usually per application, not per solution. So the .config
file way might not be how you want to go about this.

You should just save your config settings in some xml file and then attach
it to the solution as a secondary data source. Otherwise you will need to
create a solution as full trust to get it to read files off disk.

Signature

Andrew J. Ma
Software Test Engineer
Microsoft Office InfoPath
http://blogs.msdn.com/ajma
---------------------------------------
This posting is provided "As Is" with no warranties, and confers no rights.
Use of any included script sample are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm.
Please do not send email directly to this alias.  This alias is for
newsgroup purposes only.

> In a Web- or Windows-application you use ConfigurationSettings.AppSettings
> to read from a .config-file. I'd like to do the same in the
[quoted text clipped - 4 lines]
> Is there a way to use the standard xml-configfile or should I write my own
> configfile handler?
Matthew Blain \(Serriform\) - 13 Jul 2004 05:21 GMT
Check the value of
AppDomain.CurrentDomain.SetupInformation.ConfigurationFile.

I don't know how InfoPath creates its appdomains, but a custom config file
as Greg suggests is certainly going to work and has less 'appdomain' issues.

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

> Have you tried naming it INFOPATH.EXE.CONFIG.
> I'm not familiar with how Windows apps handle it, but as far as I know, this
[quoted text clipped - 14 lines]
> > Is there a way to use the standard xml-configfile or should I write my own
> > configfile handler?
StefanO-nl - 13 Jul 2004 14:08 GMT
> Have you tried naming it INFOPATH.EXE.CONFIG.

and "Matthew Blain (Serriform)" wrote:
> Check the value of
> AppDomain.CurrentDomain.SetupInformation.ConfigurationFile.

I've checked that value; it was:
@"C:\Program Files\Microsoft Office\OFFICE11\INFOPATH.EXE.config"
So you're right. It's probably not the way I want to proceed... -Although it works fine and I might use it anyway :-)

Using a secondary data source isn't the right solution for me as well, because when I publish my form (which is fully trusted btw) it will become part of the xsn-file and this is not what I want either...
Greg Collins [MVP] - 13 Jul 2004 17:14 GMT
When adding a data connection (in this case a config.xml file), InfoPath asks you, at the last step, if you want this file included as part of the form. I haven't tried it myself, but I believe that if you say "No", that it will use a hard-coded full path to that resource.

My assumption (not having tried this) is that if the resource is hosted on a server, as long as the other users have the same path access to that stored location that the config.xml file does not need to be part of the XSN and can still be accessed.

If you play with this, please post your findings as I haven't had time to try it, but am currious if it works as I expect.

Signature

Greg Collins [InfoPath MVP]
Please visit: http://www.InfoPathDev.com

"Andrew Ma [MSFT]" wrote:
> Have you tried naming it INFOPATH.EXE.CONFIG.

and "Matthew Blain (Serriform)" wrote:
> Check the value of
> AppDomain.CurrentDomain.SetupInformation.ConfigurationFile.

I've checked that value; it was:
@"C:\Program Files\Microsoft Office\OFFICE11\INFOPATH.EXE.config"
So you're right. It's probably not the way I want to proceed... -Although it works fine and I might use it anyway :-)

Using a secondary data source isn't the right solution for me as well, because when I publish my form (which is fully trusted btw) it will become part of the xsn-file and this is not what I want either...
Matthew Blain \(Serriform\) - 13 Jul 2004 22:35 GMT
Yes, it works just fine. If you have it on an HTTP server, it will even be
loaded from the wininet cache and sometimes work offline. (Also sometimes
get out of date if you're editing the file, but that's a rare and
understandable case.)

I wish InfoPath let you have controled caching of secondary data sources
such as config files, as this is a very common scenario.

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

When adding a data connection (in this case a config.xml file), InfoPath
asks you, at the last step, if you want this file included as part of the
form. I haven't tried it myself, but I believe that if you say "No", that it
will use a hard-coded full path to that resource.

My assumption (not having tried this) is that if the resource is hosted on a
server, as long as the other users have the same path access to that stored
location that the config.xml file does not need to be part of the XSN and
can still be accessed.

If you play with this, please post your findings as I haven't had time to
try it, but am currious if it works as I expect.

Signature

Greg Collins [InfoPath MVP]
Please visit: http://www.InfoPathDev.com

"Andrew Ma [MSFT]" wrote:
> Have you tried naming it INFOPATH.EXE.CONFIG.

and "Matthew Blain (Serriform)" wrote:
> Check the value of
> AppDomain.CurrentDomain.SetupInformation.ConfigurationFile.

I've checked that value; it was:
@"C:\Program Files\Microsoft Office\OFFICE11\INFOPATH.EXE.config"
So you're right. It's probably not the way I want to proceed... -Although it
works fine and I might use it anyway :-)

Using a secondary data source isn't the right solution for me as well,
because when I publish my form (which is fully trusted btw) it will become
part of the xsn-file and this is not what I want either...
StefanO-nl - 14 Jul 2004 10:38 GMT
> When adding a data connection (in this case a config.xml file),
> InfoPath asks you, at the last step, if you want this file included
> as part of the form.

Yes, when the secondary datasource isn't a resource file yet, you will be asked if you want to include this file as part of the form and when you say Yes, it will become a resource file.

It works fine using the config.xml as a resource file. It also works if you don't use a resource file but a hard coded path (saying No when asked to include the file as part of the form).

The con of this solution however is that this folder must exist on every client PC. If InfoPath can't find the file, it will display this errormessage:
The following DataObject either cannot be created or cannot be initialized: Config
The query cannot be run for the following DataObject: Config
InfoPath cannot run the specified query.
InfoPath cannot open the following file: Config.xml.
The system cannot find the file specified.

This error is shown both when I remove the resource file (in the first scenario) as well as when I remove the full path in the manifest.xsf (in the second scenario). I've tried several folders for my config.xml-file (same as the xsn-file, c:\program files\microsoft office\office11), but I keep getting this error.

And even if I would solve this problem of finding out what the folder config.xml must be, I have another problem: The error is before the OnLoad-event and therefore can't be catched to show a user friendly error dialog...

I'd expect more support of InfoPath for config-files.
Matthew Blain \(Serriform\) - 14 Jul 2004 21:42 GMT
Where is the XSN stored?

> > When adding a data connection (in this case a config.xml file),
> > InfoPath asks you, at the last step, if you want this file included
> > as part of the form.
>
> Yes, when the secondary datasource isn't a resource file yet, you will be asked if you want to include this file as part of the form and when you say
Yes, it will become a resource file.

> It works fine using the config.xml as a resource file. It also works if you don't use a resource file but a hard coded path (saying No when asked to
include the file as part of the form).

> The con of this solution however is that this folder must exist on every client PC. If InfoPath can't find the file, it will display this
errormessage:
> The following DataObject either cannot be created or cannot be initialized: Config
> The query cannot be run for the following DataObject: Config
[quoted text clipped - 3 lines]
>
> This error is shown both when I remove the resource file (in the first scenario) as well as when I remove the full path in the manifest.xsf (in the
second scenario). I've tried several folders for my config.xml-file (same as
the xsn-file, c:\program files\microsoft office\office11), but I keep
getting this error.

> And even if I would solve this problem of finding out what the folder config.xml must be, I have another problem: The error is before the
OnLoad-event and therefore can't be catched to show a user friendly error
dialog...

> I'd expect more support of InfoPath for config-files.
StefanO-nl - 16 Jul 2004 13:40 GMT
Local file system of the end user, so it could be different for every client.

"Matthew Blain (Serriform)" wrote:

> Where is the XSN stored?
>
[quoted text clipped - 32 lines]
> >
> > I'd expect more support of InfoPath for config-files.
Matthew Blain \(Serriform\) - 16 Jul 2004 19:27 GMT
How does the form get onto the user's machine? Will each user have a
different config file? If it's a fully trusted form, you could specify any
location you wanted to for a config file. If it's not, what you can do is
limited.

> Local file system of the end user, so it could be different for every client.
>
[quoted text clipped - 36 lines]
> > >
> > > I'd expect more support of InfoPath for config-files.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.