Re: WSE2.0 Security Exception ?



Hi,
I am getting the same error here, but from a windows service application
that is simply trying to read its app config file. The service is able to
read its config file on my development machine with no problem, However, on
a Win2000 machine I get the exception.

The first thought was permissions, however I am running my service under an
administrator account. The problem (to me) appears to be when using the
System.Xml.XmlNode class. Below is a copy of the config file the app is
reading and the code that reads it (sorry for the poor formatting). Any
help, or thoughts are appreciated.

Regards

*************** The application configuration file
**********************************
<?xml version="1.0" encoding="utf-8" ?>
<!-- Make the necessary changes to this configuration file and restsrt
the application to apply them.
-->
<configuration>
<configSections>
<section name="ConfigurationFileHandlerMonitors"
type="iCheck.PIE.Support.Services.ConfigFileHandler.ConfigFileHandlerConfigurationFile, ConfigFileHandler" />
</configSections>

<appSettings>
<add key="FileCopyRetryAttempts" value="5"/> <!-- Copy retries, if value
is less than 1 or greater than 60, default value 5 is used.-->
<add key="SystemFolderRegExMatchPattern" value="\\(PRD|SIT)\\"/> <!--
Regular expression for system folder matches \SIT\ or \PRD\.-->
<add key="CompanyFolderRegExMatchPattern" value="\\C\d{1,2}\\"/> <!--
Regular expression for company folder matches \C2,\C3, \C02, or \C03.-->
<add key="RPCFolderRegExMatchPattern" value="\\R\d{2}\\"/> <!-- Regular
expression for RPC folder matches R62, R67, etc.-->
<add key="TrigFolderRegExMatchPattern" value="\\(data|flag)\\"/> <!--
Regular expression for trigger folder. matches data or flag. -->
</appSettings>
<ConfigurationFileHandlerMonitors>
<FileHandlerInstance MonitorPath="C:\Test" FileFilter="*.o*1"
IncludeSubfolders="true" ScanOnStartUp="false" BusDateOffsetHours="-5"
AfterProcessEvent="CopyFile">
<FilesToCopy>
<FileName
FileRegExMatchPattern="C\d{1,2}R\d{2}(minisort1|sort1)_\d{8}.(vce|tif)$"
FileLocation="C:\\Test\\(PRD|SIT)\\C\d{1,2}\\R\d{2}"
RegExMatchFileLocation="true"
AfterCopyEvent="RenameFile" AfterCopyEventLocation=""/>
</FilesToCopy>
<CopyDestinations>
<CopyDestination BasePath="\\usclt-pia-w31\ConnectDirect\Outbound"
UseSystemFolder="true" UseCompanyFolder="true" UseRPCFolder="true"
UseBusDateFolder="false" UseTrigFolder="true"/>
</CopyDestinations>
</FileHandlerInstance>
</ConfigurationFileHandlerMonitors>
</configuration>
********************** End of the application configuration file
*******************

********************** Custom Code that reads the configuration file
******************
public Object Create (Object anObjectParent, Object anObjectConfigContext,
XmlNode xmlSection)
{
string strMonitorPath;
string strFileFilter;
string strAfterProcessEvent;

bool bIncludeSubfolders;
bool bScanOnStartup;
int iBusDateHoursOffset;

Hashtable htFileHandlerInstance = new Hashtable(); // Stores each
instance of a file handler.

// Get each FileHandlerInstance XML node section and parse its
attributes, etc.
//
XmlNodeList xmlFileHandlersList =
xmlSection.SelectNodes("FileHandlerInstance");
foreach(XmlNode xmlFileHandlerInstance in xmlFileHandlersList)
{
Hashtable htFilesToCopy = new Hashtable(); // Stores the files to
copy information.
Hashtable htCopyDestination = new Hashtable(); // Stores the copy
detination information.

strMonitorPath =
xmlFileHandlerInstance.Attributes["MonitorPath"].Value;
strFileFilter =
xmlFileHandlerInstance.Attributes["FileFilter"].Value;
bIncludeSubfolders =
Convert.ToBoolean(xmlFileHandlerInstance.Attributes["IncludeSubfolders"].Value.ToLower());
bScanOnStartup =
Convert.ToBoolean(xmlFileHandlerInstance.Attributes["ScanOnStartUp"].Value.ToLower());
iBusDateHoursOffset =
Convert.ToInt32(xmlFileHandlerInstance.Attributes["BusDateOffsetHours"].Value);
strAfterProcessEvent =
xmlFileHandlerInstance.Attributes["AfterProcessEvent"].Value;
//
// Get the FilesToCopy XML node, then the FileName nodes. Validation is
performed on the attributes.
//
XmlNode xmlFilesToCopy =
xmlFileHandlerInstance.SelectSingleNode("FilesToCopy");
XmlNodeList xmlFileNameList = xmlFilesToCopy.SelectNodes("FileName");
foreach(XmlNode xmlFileName in xmlFileNameList)
{
string strAfterCopyEvent;
string strAfterCopyEventLocation;
string strFileLocation;
string strRegExMatchFileLocation;

strFileLocation = xmlFileName.Attributes["FileLocation"].Value;

try
{
strRegExMatchFileLocation =
xmlFileName.Attributes["RegExMatchFileLocation"].Value.ToLower();
}

catch(Exception Err)
{
strRegExMatchFileLocation = "false";
string strDescription = string.Format("The RegExMatchFileLocation is
not set or is invalid, setting value to false. {0}",
Err.Message);
ConfigFileHandlerService.LogEvent(0, strDescription,
EventLogEntryType.Warning);
}

try
{
strAfterCopyEvent = xmlFileName.Attributes["AfterCopyEvent"].Value;
}

catch (Exception Err)
{
strAfterCopyEvent = string.Empty;
string strDescription = string.Format("The AfterCopyEvent attribute is
invalid, Rename will be used as AfterCopyEvent. {0}",
Err.Message);
ConfigFileHandlerService.LogEvent(0,strDescription,
EventLogEntryType.Warning);
}

if (string.Empty != strAfterCopyEvent)
{
try
{
strAfterCopyEventLocation =
xmlFileName.Attributes["AfterCopyEventLocation"].Value;
}

catch (Exception Err)
{
strAfterCopyEventLocation = string.Empty;
string strDescription = string.Format("The AfterCopyEventLocation is
invalid, [{0}] will be used as the AfterCopyEventLocation. {1}",
strFileLocation, Err.Message);
ConfigFileHandlerService.LogEvent(0, strDescription,
EventLogEntryType.Warning);
}
}
else
{
strAfterCopyEventLocation = string.Empty;
string strDescription = string.Format("The AfterCopyEvent is invalid,
therefore Rename will be used. [{0}] will be used as the
AfterCopyEventLocation",
strFileLocation);
ConfigFileHandlerService.LogEvent(0, strDescription,
EventLogEntryType.Warning);
}

// Store the FileName attribute values into a hashtable using the
FileRegExMatchPattern value as the hash key.
// Any duplicates will be ignored.
//
try
{
htFilesToCopy.Add(xmlFileName.Attributes["FileRegExMatchPattern"].Value, string.Format("{0};{1};{2};{3}",
strFileLocation, strRegExMatchFileLocation, strAfterCopyEvent,
strAfterCopyEventLocation));
}

catch(ArgumentException)
{
string strDescription = string.Format("Duplicate FileRegExMatchPattern
attribute detected, it will be ignored.");
ConfigFileHandlerService.LogEvent(0, strDescription,
EventLogEntryType.Warning);
}
}

// Get the CopyDestinations node, then the CopyDestination nodes.
Validation is performed on the attributes.
//
XmlNode xmlCopyDestinations =
xmlFileHandlerInstance.SelectSingleNode("CopyDestinations");
XmlNodeList xmlCopyDestinationsList =
xmlCopyDestinations.SelectNodes("CopyDestination");
foreach(XmlNode xmlCopyDestination in xmlCopyDestinations)
{
string strUseSystemFolder;
string strUseRPCFolder;
string strUseCompanyFolder;
string strUseBusDateFolder;
string strUseTrigFolder;

try
{
strUseSystemFolder =
xmlCopyDestination.Attributes["UseSystemFolder"].Value;
}

catch(Exception Err)
{
strUseSystemFolder = "false";
string strDescription = string.Format("The UseSystemFolder value is
not set or is invalid, setting value to false. {0}",
Err.Message);
ConfigFileHandlerService.LogEvent(0,strDescription,EventLogEntryType.Warning);
}

try
{
strUseCompanyFolder =
xmlCopyDestination.Attributes["UseCompanyFolder"].Value;
}

catch(Exception Err)
{
strUseCompanyFolder = "false";
string strDescription = string.Format("The UseCompanyFolder value is
not set or is invalid, setting value to false. {0}",
Err.Message);
ConfigFileHandlerService.LogEvent(0, strDescription,
EventLogEntryType.Warning);
}

try
{
strUseRPCFolder = xmlCopyDestination.Attributes["UseRPCFolder"].Value;
}

catch(Exception Err)
{
strUseRPCFolder = "false";
string strDescription = string.Format("The UseRPCFolder value is not
set or is invalid, setting value to false. {0}",
Err.Message);
ConfigFileHandlerService.LogEvent(0, strDescription,
EventLogEntryType.Warning);
}

try
{
strUseBusDateFolder =
xmlCopyDestination.Attributes["UseBusDateFolder"].Value;
}

catch(Exception Err)
{
strUseBusDateFolder = "false";
string strDescription = string.Format("The UseBusDateFolder value is
not set or is invalid, setting value to false. {0}.",
Err.Message);
ConfigFileHandlerService.LogEvent(0, strDescription,
EventLogEntryType.Warning);
}

try
{
strUseTrigFolder = xmlCopyDestination.Attributes["UseTrigFolder"].Value;
}

catch(Exception Err)
{
strUseTrigFolder = "false";
string strDescription = string.Format("The UseTrigFolder value is not
set or is invalid, setting value to false. {0}.",
Err.Message);
ConfigFileHandlerService.LogEvent(0, strDescription,
EventLogEntryType.Warning);
}
// Store the CopyDestinations into a hashtable, using the base path as
the hash key.
// Any duplicates are ignored.
//
try
{
htCopyDestination.Add(xmlCopyDestination.Attributes["BasePath"].Value,
string.Format("{0};{1};{2};{3};{4}",
strUseSystemFolder, strUseCompanyFolder, strUseRPCFolder,
strUseBusDateFolder, strUseTrigFolder));
}

catch(ArgumentException)
{
string strDescription = "Duplicate BasePath attribute detected, it
will be ignored.";
ConfigFileHandlerService.LogEvent(0, strDescription,
EventLogEntryType.Warning);
}
}
//
// Create an instance of the CongigFileHandler class, passing in its
configuration information.
// Add the instance to the hashtable.
// The UniqueHashKey consists of the strMonitorPath and the
strFileFilter varaibles.
//
try
{
ConfigFileHandlerMonitor cfhmInstance = new
ConfigFileHandlerMonitor(strMonitorPath, strFileFilter, bIncludeSubfolders,
bScanOnStartup, iBusDateHoursOffset, strAfterProcessEvent,
htFilesToCopy, htCopyDestination);
htFileHandlerInstance.Add(cfhmInstance.UniqueHashKey, cfhmInstance);
//
// Clear the hashtables for use with the next ConfigFileHandlerMonitor
object.
//
//htFilesToCopy.Clear();
//htCopyDestination.Clear();
}

catch(ArgumentException)
{
string strDescription = "Duplicate FileInstanceHandler attributes
detected, it will be ignored.";
ConfigFileHandlerService.LogEvent(0, strDescription,
EventLogEntryType.Warning);
}
}

return htFileHandlerInstance;
}
***************** End of the custom code that reads the configuration file
******************

"Marvin Smit" wrote:

> Hi,
>
> One more thing that jumped into my mind (i donno if its relevant
> but...) I know there was a change in drive mappings for different user
> accounts in W2K3.
>
> Are u using an UNC path?
>
> Marvin Smit
>
> On Tue, 02 Aug 2005 15:10:00 -0400, Ben Bloom
> <bbloom@xxxxxxxxxxxxxxxxxxxxxx> wrote:
>
> >Anyone have any idea why I would get errors running an app from a
> >network drive, but enabling the app to have Full Trust? I have no
> >problem running the app from a local drive.
> >
> >This problem seems to be specific to 2003, as I can permission the same
> >executable with full trust on a Win2k box without error.
> >
> >Thanks,
> >
> >
> >Ben Bloom wrote:
> >
> >> Hi Marvin,
> >>
> >> I'm running both apps (production and my test app) off of a network
> >> drive. I have permissioned them both with full trust via the .NET Wizard.
> >>
> >> Thanks
> >> -Ben
> >>
> >>
> >>
> >> Marvin Smit wrote:
> >>
> >>> Hi,
> >>>
> >>> I think the root of the problem lies in the security area. You are
> >>> getting a "Request for the permission of type
> >>> System.Net.DnsPermission.... failed".
> >>> Are you running the Client app in something else than full trust?
> >>>
> >>> Hope this helps,
> >>>
> >>> Marvin Smit
> >>>
> >>>
> >>>
> >>> On Fri, 29 Jul 2005 10:10:33 -0400, Ben Bloom
> >>> <bbloom@xxxxxxxxxxxxxxxxxxxxxx> wrote:
> >>>
> >>>
> >>>> Hello,
> >>>>
> >>>> I've been wrestling with getting a WSE2 enabled client installed on a
> >>>> Windows 2003 server. It works from other machines (not 2003) but not
> >>>> this one. I created a test application that consumes the same web
> >>>> service, instead of my production application, and I get the
> >>>> exception below.
> >>>>
> >>>> What does this mean? How do I solve this problem?
> >>>>
> >>>> Thanks,
> >>>> -Ben
> >>>>
> >>>>
> >>>>
> >>>>
> >>>> See the end of this message for details on invoking
> >>>> just-in-time (JIT) debugging instead of this dialog box.
> >>>>
> >>>> ************** Exception Text **************
> >>>> System.Configuration.ConfigurationException: WSE032: There was an
> >>>> error loading the microsoft.web.services2 configuration section. --->
> >>>> System.Configuration.ConfigurationException: Exception in
> >>>> configuration section handler (M:\Interfaces\PBCONFIGURE\tester\web
> >>>> service tester.exe.config line 6) --->
> >>>> System.Security.SecurityException: Request for the permission of type
> >>>> System.Net.DnsPermission, System, Version=1.0.5000.0,
> >>>> Culture=neutral, PublicKeyToken=b77a5c561934e089 failed.
> >>>> at
> >>>> System.Security.SecurityRuntime.FrameDescHelper(FrameSecurityDescriptor
> >>>> secDesc, IPermission demand, PermissionToken permToken)
> >>>> at System.Security.CodeAccessSecurityEngine.Check(PermissionToken
> >>>> permToken, CodeAccessPermission demand, StackCrawlMark& stackMark,
> >>>> Int32 checkFrames, Int32 unrestrictedOverride)
> >>>> at
> >>>> System.Security.CodeAccessSecurityEngine.Check(CodeAccessPermission
> >>>> cap, StackCrawlMark& stackMark)
> >>>> at System.Security.CodeAccessPermission.Demand()
> >>>> at System.Net.Dns.GetHostName()
> >>>> at
> >>>> Microsoft.Web.Services2.Messaging.SoapTcpTransport..ctor(XmlNodeList
> >>>> configData)
> >>>> at
> >>>> Microsoft.Web.Services2.Messaging.Configuration.MessagingConfiguration..ctor()
> >>>>
> >>>> at
> >>>> Microsoft.Web.Services2.Configuration.WebServicesConfiguration.Clear()
> >>>> at
> >>>> Microsoft.Web.Services2.Configuration.WebServicesConfiguration.System.Configuration.IConfigurationSectionHandler.Create(Object
> >>>> parent, Object configContext, XmlNode section)
> >>>> at
> >>>> System.Configuration.ConfigurationRecord.EvaluateRecursive(IConfigurationSectionHandler
> >>>> factory, Object config, String[] keys, Int32 iKey, XmlTextReader reader)
> >>>>
> >>>> The state of the failed permission was:
> >>>> <IPermission class="System.Net.DnsPermission, System,
> >>>> Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
> >>>> version="1"
> >>>> Unrestricted="true"/>
> >>>>
> >>>> --- End of inner exception stack trace ---
> >>>> at
> >>>> System.Configuration.ConfigurationRecord.EvaluateRecursive(IConfigurationSectionHandler
> >>>> factory, Object config, String[] keys, Int32 iKey, XmlTextReader reader)
> >>>> at System.Configuration.ConfigurationRecord.Evaluate(String configKey)
> >>>> at System.Configuration.ConfigurationRecord.ResolveConfig(String
> >>>> configKey)
> >>>> at System.Configuration.ConfigurationRecord.GetConfig(String
> >>>> configKey)
> >>>> at
> >>>> System.Configuration.DefaultConfigurationSystem.System.Configuration.IConfigurationSystem.GetConfig(String
> >>>> configKey)
> >>>> at System.Configuration.ConfigurationSettings.GetConfig(String
> >>>> sectionName)
> >>>> at
> >>>> Microsoft.Web.Services2.Configuration.WebServicesConfiguration.Initialize()
> >>>>
> >>>> --- End of inner exception stack trace ---
> >>>> at
> >>>> Microsoft.Web.Services2.Configuration.WebServicesConfiguration.Initialize()
> >>>>
> >>>> at Microsoft.Web.Services2.Referral.ReferralCache.Initialize()
> >>>> at Microsoft.Web.Services2.Referral.ReferralCache.ResolvePath(Uri uri)
> >>>> at
> >>>> Microsoft.Web.Services2.WebServicesClientProtocol.set_Destination(EndpointReference
> >>>> value)
> >>>> at Microsoft.Web.Services2.WebServicesClientProtocol.set_Url(String
> >>>> value)
> >>>> at web_service_tester.proxy.eodWse..ctor()
> >>>> at web_service_tester.Form1.button1_Click(Object sender, EventArgs e)
> >>>> at System.Windows.Forms.Control.OnClick(EventArgs e)
> >>>> at System.Windows.Forms.Button.OnClick(EventArgs e)
> >>>> at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
> >>>> at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons
> >>>> button, Int32 clicks)
> >>>> at System.Windows.Forms.Control.WndProc(Message& m)
> >>>> at System.Windows.Forms.ButtonBase.WndProc(Message& m)
> >>>> at System.Windows.Forms.Button.WndProc(Message& m)
> >>>> at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)
> >>>> at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)
> >>>> at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32
> >>>> msg, IntPtr wparam, IntPtr lparam)
> >>>>
> >>>>
> >>>> ************** Loaded Assemblies **************
> >>>> mscorlib
> >>>> Assembly Version: 1.0.5000.0
> >>>> Win32 Version: 1.1.4322.2032
> >>>> CodeBase:
> >>>> file:///c:/windows/microsoft.net/framework/v1.1.4322/mscorlib.dll
> >>>> ----------------------------------------
> >>>> System
> >>>> Assembly Version: 1.0.5000.0
> >>>> Win32 Version: 1.1.4322.2032
> >>>> CodeBase:
> >>>> file:///c:/windows/assembly/gac/system/1.0.5000.0__b77a5c561934e089/system.dll
> >>>>
> >>>> ----------------------------------------
> >>>> System.Drawing
> >>>> Assembly Version: 1.0.5000.0
> >>>> Win32 Version: 1.1.4322.2032
> >>>> CodeBase:
> >>>> file:///c:/windows/assembly/gac/system.drawing/1.0.5000.0__b03f5f7f11d50a3a/system.drawing.dll
> >>>>
> >>>> ----------------------------------------
> >>>> web service tester
> >>>> Assembly Version: 1.0.2036.16026
> >>>> Win32 Version: 1.0.2036.16026
> >>>> CodeBase:
> >>>> file:///M:/Interfaces/PBCONFIGURE/tester/web%20service%20tester.exe
> >>>> ----------------------------------------
> >>>> System.Windows.Forms
> >>>> Assembly Version: 1.0.5000.0
> >>>> Win32 Version: 1.1.4322.2032
> >>>> CodeBase:
> >>>> file:///c:/windows/assembly/gac/system.windows.forms/1.0.5000.0__b77a5c561934e089/system.windows.forms.dll
> >>>>
> >>>> ----------------------------------------
> >>>> Microsoft.Web.Services2
> >>>> Assembly Version: 2.0.0.0
> >>>> Win32 Version: 2.0.4135.0
> >>>> CodeBase:
> >>>> file:///c:/windows/assembly/gac/microsoft.web.services2/2.0.0.0__31bf3856ad364e35/microsoft.web.services2.dll
> >>>>
> >>>> ----------------------------------------
> >>>> System.Web.Services
> >>>> Assembly Version: 1.0.5000.0
> >>>> Win32 Version: 1.1.4322.2032
> >>>> CodeBase:
> >>>> file:///c:/windows/assembly/gac/system.web.services/1.0.5000.0__b03f5f7f11d50a3a/system.web.services.dll
> >>>>
> >>>> ----------------------------------------
> >>>> System.Xml
> >>>> Assembly Version: 1.0.5000.0
> >>>> Win32 Version: 1.1.4322.2032
> >>>> CodeBase:
> >>>> file:///c:/windows/assembly/gac/system.xml/1.0.5000.0__b77a5c561934e089/system.xml.dll
> >>>>
> >>>> ----------------------------------------
> >>>> System.Web
> >>>> Assembly Version: 1.0.5000.0
> >>>> Win32 Version: 1.1.4322.2032
> >>>> CodeBase:
> >>>> file:///c:/windows/assembly/gac/system.web/1.0.5000.0__b03f5f7f11d50a3a/system.web.dll
> >>>>
> >>>> ----------------------------------------
> >>>> kfpvbvqf
> >>>> Assembly Version: 0.0.0.0
> >>>> Win32 Version: 1.1.4322.2032
> >>>> CodeBase:
> >>>> file:///c:/windows/assembly/gac/system/1.0.5000.0__b77a5c561934e089/system.dll
> >>>>
> >>>> ----------------------------------------
> >>>> System.Security
> >>>> Assembly Version: 1.0.5000.0
> >>>> Win32 Version: 1.1.4322.2032
> >>>> CodeBase:
> >>>> file:///c:/windows/assembly/gac/system.security/1.0.5000.0__b03f5f7f11d50a3a/system.security.dll
> >>>>
> >>>> ----------------------------------------
> >>>>
> >>>> ************** JIT Debugging **************
> >>>> To enable just in time (JIT) debugging, the config file for this
> >>>> application or machine (machine.config) must have the
> >>>> jitDebugging value set in the system.windows.forms section.
> >>>> The application must also be compiled with debugging
> >>>> enabled.
> >>>>
> >>>> For example:
> >>>>
> >>>> <configuration>
> >>>> <system.windows.forms jitDebugging="true" />
> >>>> </configuration>
> >>>>
> >>>> When JIT debugging is enabled, any unhandled exception
> >>>> will be sent to the JIT debugger registered on the machine
> >>>> rather than being handled by this dialog.
> >>>>
> >>>
> >>>
> >>
> >>
>
>
.