OK, I think I've gotten to the bottom of this issue.
I building myself a little test application.
using System;
using System.Net;
using System.IO;
namespace OpenReadTestApp
{
/// <summary>
/// Summary description for Class1.
/// </summary>
class Class1
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
try
{
System.Net.WebClient webClient = new System.Net.WebClient();
string fullName = "http://10.2.5.210/Components/Config.Default.Xml";
Console.WriteLine( "fetching stream for : "+fullName);
Stream s = webClient.OpenRead(fullName);
Console.WriteLine( "OK" );
Console.ReadLine();
}
catch( Exception e )
{
Console.WriteLine( e );
Console.ReadLine();
}
}
}
}
This works fine when run from on a win2k3 client ( launching the app via
href ) with win2k3 sp1 or not, which i wasn't expecting.
My app was still throwing the following error, which suggested a problem
around configuration settings.
System.Net.WebException: An Exception occurred during a WebClient request.
--> System.NullReferenceException : Object reference not set to an instance
of an object.
at System.Configuration.DefaultConfigurationSystem..c tor()
at System.Configuration.ConfigurationSettings.EnsureC onfigurationSystem()
at System.Configuration.ConfigurationSettings.GetConf ig(Sring sectionName)
at System.Net.WebRequest.get_PrefixList()
at System.Net.WebRequest.Create(Uri requestUri, Boolean useUriBase)
at System.Net.WebRequest.Create(Uri requestUri)
at System.Net.WebClient.Openead(String address)
--- End of inner exception stack trace ---
at System.Net.WebClient.OpenRead(String address)
at Softix.Platform.Utils.Config.OpenRelativeFileName( String fileName)
Turns out, due to some problem earlier in development, we'd stopped using
the app config file, and had hit some problem with win2k boxes,
whereby we were getting an error with some service pack combinations if the
app.config file wasn't present.
The workaround had been to add the following line early in the application
startup.
AppDomain.CurrentDomain.SetData("APP_CONFIG_FILE", "");
We'd subsequently started to use the app.config file, and without noticeable
problem, even though we'd left the above line in the code.
Seems a win2k3 client, with sp1, throws an error when doing an open read if
you have set the app_config_file to "", whether you have an app.config file
present or not.
Without sp1, the app carries on regardless, without any noticeable impact,
though i wonder if its actually reading the app.config file correctly.
Note, we are only using the app.config file to set the codebase so that IIS
doesn't do excessive probing for .exe and app.config file in various
locations, which is a whole different story. I'll have to do more testing to
ascertain if things are working properly for all circumstances, but i think
that they will be now.
Anyway, problem solved. If i remove
AppDomain.CurrentDomain.SetData("APP_CONFIG_FILE", ""); the application works
correctly from any win2k3 client
whether it has sp1 or not.
Thanks for your time.
"Kevin Yu [MSFT]" wrote:
You're welcome, please post to this thread after a day or two, and I will
follow it up.
Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."