path is not of a legal form for FileSystemWatcher if I get path fromAppSettings

P

pantagruel

Hi,

the following:

FileSystemWatcher watcher = new FileSystemWatcher();
RenderingQ = ConfigurationSettings.AppSettings["RenderingQ"];
//RenderingQ = "C:\\RenditionServerQ\\InjectorQ\\OnDemandQ";
watcher.Path = RenderingQ;

raises the following error:

An unhandled exception of type 'System.ArgumentException' occurred in
mscorlib.dll

Additional information: The path is not of a legal form.

It's somewhat weird because
1. I have tried with both C:\\RenditionServerQ\\InjectorQ\\OnDemandQ
and C:\RenditionServerQ\InjectorQ\OnDemandQ as the value of the
RenderingQ configuration app settings.

2. RenderingQ is declared as a string.

The configuration settings are as follows:

<userSettings>
<WindowsService2.Properties.Settings>
<setting name="RenderingQ" serializeAs="String">
<value>C:\RenditionServerQ\InjectorQ\OnDemandQ</value>
</setting>
</WindowsService2.Properties.Settings>
</userSettings>


If I do the following:

EventLog.WriteEntry(ConfigurationManager.AppSettings["RenderingQ"]);
I get a blank entry in the event log. So what's that about?
 
F

Family Tree Mike

Well, I think that getting a blank in the event log is telling you there is
something wrong with the setting that you are loading. A blank value would
give you an illegal form error for the path on the file system watcher.
 
P

pantagruel

Yeah, I suppose there's something wrong as well. But I can't really
see what that is. The setting name is the same as the value I am
passing, certainly looks like it above. I've tried two different path
values.
I've tried with both ConfigurationManager.AppSettings and
ConfigurationSettings.AppSettings,

So the question is why would this as my app settings:

<userSettings>
<WindowsService2.Properties.Settings>
<setting name="RenderingQ" serializeAs="String">
<value>C:\RenditionServerQ\InjectorQ\OnDemandQ</value>
</setting>
</WindowsService2.Properties.Settings>
</userSettings>

give a blank value for this


ConfigurationManager.AppSettings["RenderingQ"]



Well, I think that getting a blank in the event log is telling you there is
something wrong with the setting that you are loading. A blank value would
give you an illegal form error for the path on the file system watcher.

pantagruel said:
the following:
FileSystemWatcher watcher = new FileSystemWatcher();
RenderingQ = ConfigurationSettings.AppSettings["RenderingQ"];
//RenderingQ = "C:\\RenditionServerQ\\InjectorQ\\OnDemandQ";
watcher.Path = RenderingQ;
raises the following error:
An unhandled exception of type 'System.ArgumentException' occurred in
mscorlib.dll
Additional information: The path is not of a legal form.
It's somewhat weird because
1. I have tried with both C:\\RenditionServerQ\\InjectorQ\\OnDemandQ
and C:\RenditionServerQ\InjectorQ\OnDemandQ as the value of the
RenderingQ configuration app settings.
2. RenderingQ is declared as a string.
The configuration settings are as follows:
<userSettings>
<WindowsService2.Properties.Settings>
<setting name="RenderingQ" serializeAs="String">
<value>C:\RenditionServerQ\InjectorQ\OnDemandQ</value>
</setting>
</WindowsService2.Properties.Settings>
</userSettings>
If I do the following:
EventLog.WriteEntry(ConfigurationManager.AppSettings["RenderingQ"]);
I get a blank entry in the event log. So what's that about?
 
F

Family Tree Mike

Are you getting any values from your settings that are valid?

If not, try something like the following and see if your code is having
trouble finding the config file.

string[] keys = appSettings.AllKeys;

Console.WriteLine();
Console.WriteLine("Application appSettings:");

// Loop to get key/value pairs.
for (int i = 0; i < appSettings.Count; i++)

Console.WriteLine("#{0} Name: {1} Value: {2}",
i, keys, appSettings);



pantagruel said:
Yeah, I suppose there's something wrong as well. But I can't really
see what that is. The setting name is the same as the value I am
passing, certainly looks like it above. I've tried two different path
values.
I've tried with both ConfigurationManager.AppSettings and
ConfigurationSettings.AppSettings,

So the question is why would this as my app settings:

<userSettings>
<WindowsService2.Properties.Settings>
<setting name="RenderingQ" serializeAs="String">
<value>C:\RenditionServerQ\InjectorQ\OnDemandQ</value>
</setting>
</WindowsService2.Properties.Settings>
</userSettings>

give a blank value for this


ConfigurationManager.AppSettings["RenderingQ"]



Well, I think that getting a blank in the event log is telling you there is
something wrong with the setting that you are loading. A blank value would
give you an illegal form error for the path on the file system watcher.

pantagruel said:
the following:
FileSystemWatcher watcher = new FileSystemWatcher();
RenderingQ = ConfigurationSettings.AppSettings["RenderingQ"];
//RenderingQ = "C:\\RenditionServerQ\\InjectorQ\\OnDemandQ";
watcher.Path = RenderingQ;
raises the following error:
An unhandled exception of type 'System.ArgumentException' occurred in
mscorlib.dll
Additional information: The path is not of a legal form.
It's somewhat weird because
1. I have tried with both C:\\RenditionServerQ\\InjectorQ\\OnDemandQ
and C:\RenditionServerQ\InjectorQ\OnDemandQ as the value of the
RenderingQ configuration app settings.
2. RenderingQ is declared as a string.
The configuration settings are as follows:
<userSettings>
<WindowsService2.Properties.Settings>
<setting name="RenderingQ" serializeAs="String">
<value>C:\RenditionServerQ\InjectorQ\OnDemandQ</value>
</setting>
</WindowsService2.Properties.Settings>
</userSettings>
If I do the following:
EventLog.WriteEntry(ConfigurationManager.AppSettings["RenderingQ"]);
I get a blank entry in the event log. So what's that about?
 

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