Groups | Blog | Home
all groups > dotnet web services enhancements > july 2005 >

dotnet web services enhancements : WSE2.0 Security Exception ?


Marvin Smit
7/29/2005 12:00:00 AM
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
[quoted text, click to view]
Ben Bloom
7/29/2005 10:10:33 AM
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:
Ben Bloom
7/29/2005 10:46:07 AM
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



[quoted text, click to view]
Ben Bloom
8/2/2005 3:10:00 PM
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,


[quoted text, click to view]
Marvin Smit
8/3/2005 12:00:00 AM
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
[quoted text, click to view]
VB
8/5/2005 8:14:25 AM
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}",
Ben Bloom
8/9/2005 8:59:58 AM
Hi,

I'm using a mapped drive, when I reference the network executable. For
now, I have this issue resolved by running my app from a local drive.
Hopefully we'll be able to run it on a W2k3 networked drive eventually.

Thanks,
-Ben

[quoted text, click to view]
Ben Bloom
8/9/2005 9:00:44 AM
Hi,

I'm using a mapped drive, when I reference the network executable. For
now, I have this issue resolved by running my app from a local drive.
Hopefully we'll be able to run it on a W2k3 networked drive eventually.

Thanks,
-Ben

[quoted text, click to view]
VB
8/10/2005 11:26:08 AM
The app I am using is running on a local drive. The error occurs when the app
(a windows service) attempts to read the app config file. The app has admin
permissions, so I do not believe that is an issue.

I did notice something strange however. In Win2000, when attempting to read
the app config file, whitespace is detected, which could explain the
exception. In XP, no whitespace is detected at all. I am still researching
why this is the case. Thanks for your response.

Regards

[quoted text, click to view]
AddThis Social Bookmark Button