an ASP.NET Open Source CMS & eCommerce platform
Search:
Last Post 7/6/2009 10:13:59 AM By lukezy. 13 replies.
Page 1 of 2 (14 posts) << First < Prev 1 2 Next > Last >> 
1/19/2009 9:25:22 AM
zibi
Posts: 8
Joined: 9/15/2008
Trust level
I've just put my page on IIS 7.0 .It's working fine if i use trust level set to "Full".
If I set trust level to "Medium" or even "High" it causes exceptions.
Unfortunately the server I want to put my page on, is working on "Medium" level (and it can't be modified).
Is it possible to fix that problem?? How??
1/19/2009 2:12:41 PM
lukezy
Posts: 2109
Joined: 6/12/2007
Location:WA, US
Re: Trust level
Could you please post some of these exceptions?
DotShoppingCart Staff
1/19/2009 2:29:05 PM
zibi
Posts: 8
Joined: 9/15/2008
Re: Trust level
The exception looks like this:
 
Server Error in '/' Application

Required permissions cannot be acquired.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Security.Policy.PolicyException: Required permissions cannot be acquired.

Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:
[PolicyException: Required permissions cannot be acquired.]
System.Security.SecurityManager.ResolvePolicy(Evidence evidence, PermissionSet reqdPset, PermissionSet optPset, PermissionSet denyPset, PermissionSet& denied, Boolean checkExecutionPermission) +2736869
System.Security.SecurityManager.ResolvePolicy(Evidence evidence, PermissionSet reqdPset, PermissionSet optPset, PermissionSet denyPset, PermissionSet& denied, Int32& securitySpecialFlags, Boolean checkExecutionPermission) +57
 
I found out that there was a problem with Microsoft EnterpriseLibrary. The version of library  included in OpenSourceVersion is 2.0.
It's only working with "Full" trust level. I got the newset version from Microsoft (it's working with other trust levels) and i was trying to replace it, but there is a method Add in IConfigurationSource interface which has
2 parameters in version 2.0 and 3 in version 3.1 or 4.0. The missing paramter has type of IConfigurationParameter.
What should I do with this paramter???
I put this method below
 
IConfigurationSource configSource = ConfigurationSourceFactory.Create(ConfigurationSourceName);
configSource.Add( sectionName, clonedSection);
1/19/2009 11:10:52 PM
lukezy
Posts: 2109
Joined: 6/12/2007
Location:WA, US
Re: Trust level
I think there was a bug in EnterpriseLibrary. Try using the following ConfigurationSourceFactory.cs.
 
//===============================================================================
// Microsoft patterns & practices Enterprise Library
// Core
//===============================================================================
// Copyright © Microsoft Corporation. All rights reserved.
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY
// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT
// LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
// FITNESS FOR A PARTICULAR PURPOSE.
//===============================================================================
 
using System;
using System.Configuration;
using Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder;
using Microsoft.Practices.EnterpriseLibrary.Common.Properties;
 
namespace Microsoft.Practices.EnterpriseLibrary.Common.Configuration
{
      ///<summary>
      /// Contains factory methods to create configuration sources.
      ///</summary>
      public static class ConfigurationSourceFactory
      {
            ///<summary>
            /// Creates a new configuration sources based on the configuration information from the application's default
            /// configuration file.
            ///</summary>
            ///<param name="name">The name for the desired configuration source.</param>
            ///<returns>The new configuration source instance described in the configuration file.</returns>
            ///<exception cref="ConfigurationErrorsException">when no configuration information is found for name <paramref name="name"/>.</exception>
            ///<exception cref="ArgumentNullException">when <paramref name="name"/> is null or empty.</exception>
            public static IConfigurationSource Create(string name)
            {
                  if (string.IsNullOrEmpty(name))
                        throw new ArgumentNullException("name");
 
                  ConfigurationSourceSection configurationSourceSection
                        = ConfigurationSourceSection.GetConfigurationSourceSection();
 
                  if (configurationSourceSection == null)
                  {
                        throw new ConfigurationErrorsException(Resources.ExceptionConfigurationSourceSectionNotFound);
                  }
 
                  ConfigurationSourceElement objectConfiguration
                        = configurationSourceSection.Sources.Get(name);
 
                  if (objectConfiguration == null)
                  {
                        throw new ConfigurationErrorsException(
                              string.Format(
                                    Resources.Culture,
                                    Resources.ExceptionNamedConfigurationNotFound,
                                    name,
                                    "ConfigurationSourceFactory"));
                  }
 
                  IConfigurationSource source = objectConfiguration.CreateSource();
 
                  return source;
            }
 
            ///<summary>
            /// Creates a new configuration sources based on the default configuration information from the
            /// application's default configuration file.
            ///</summary>
            ///<returns>The new configuration source instance described as the default in the configuration file,
            /// or a new instance of <see cref="SystemConfigurationSource"/> if the is no configuration sources configuration.</returns>
            ///<exception cref="ConfigurationSourceSection">when there is a configuration section but it does not define
            /// a default configurtion source, or when the configuration for the defined default configuration source is not found.</exception>
            public static IConfigurationSource Create()
            {
                  ConfigurationSourceSection configurationSourceSection
                        = ConfigurationSourceSection.GetConfigurationSourceSection();
 
                  if (configurationSourceSection != null)
                  {
                        string systemSourceName = configurationSourceSection.SelectedSource;
                        if (!string.IsNullOrEmpty(systemSourceName))
                        {
                              return Create(systemSourceName);
                        }
                        else
                        {
                              throw new ConfigurationErrorsException(Resources.ExceptionSystemSourceNotDefined);
                        }
                  }
 
                  return new SystemConfigurationSource();
            }
      }
}
 
 
 
DotShoppingCart Staff
1/20/2009 2:36:47 AM
zibi
Posts: 8
Joined: 9/15/2008
Re: Trust level
This file looks exactly like this one from 2.0 version source code, so it won't change enything.
I've just downloaded  the latest version of EnterpriseLibrary 4.1 and i'm going to replace all dll's to latest version and build sections of web.config in EndLibConfig.exe in the same way as it's done in original version of source code. I hope this would help.
1/20/2009 6:00:25 AM
zibi
Posts: 8
Joined: 9/15/2008
Re: Trust level
I' ve changed everything to version 4.1 and got only one exception when trying to read
ModuleConfigurationSource which is in different file (Module.config).
Any ideas??
1/20/2009 3:55:29 PM
lukezy
Posts: 2109
Joined: 6/12/2007
Location:WA, US
Re: Trust level
What was the exception stack?
DotShoppingCart Staff
1/20/2009 10:34:55 PM
zibi
Posts: 8
Joined: 9/15/2008
Re: Trust level
There was a security exception
 
[SecurityException: Request for the permission of type 'System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.0.0,
 Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.]
 Here is the stack :
 DotShoppingCart.OpenSource.Core.DLL!DotShoppingCart.OpenSource.Core.ConfigurationController.GetModuleSection(string sectionName = "dynamicPageConfiguration") Line 58 + 0xb bytes	C#
 DotShoppingCart.OpenSource.Core.DLL!DotShoppingCart.OpenSource.Core.DynamicPageConfigurationSection.GetSection() Line 50 + 0xb bytes	C#
 DotShoppingCart.OpenSource.HttpModules.UrlRewriter.DLL!DotShoppingCart.OpenSource.HttpModules.UrlRewriterHttpModule.DynamicPages.get() Line 39 + 0x5 bytes	C#
 DotShoppingCart.OpenSource.HttpModules.UrlRewriter.DLL!DotShoppingCart.OpenSource.HttpModules.UrlRewriterHttpModule.BeginRequest(object sender = {ASP.global_asax}, System.EventArgs e = {System.EventArgs}) Line 107 + 0x9 bytes	C#

I'm sending section from web.config responsible for that

<section name="enterpriseLibrary.ConfigurationSource" type="Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ConfigurationSourceSection, Microsoft.Practices.EnterpriseLibrary.Common, Version=4.1.0.0, Culture=neutral,
 PublicKeyToken=31bf3856ad364e35" requirePermission="false" />

<enterpriseLibrary.ConfigurationSource selectedSource="System Configuration Source">
    <sources>
      <add name="ModuleConfigurationSource" type="Microsoft.Practices.EnterpriseLibrary.Common.Configuration.FileConfigurationSource, Microsoft.Practices.EnterpriseLibrary.Common, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
        filePath="Module.config" />
      <add name="SiteConfigurationSource" type="Microsoft.Practices.EnterpriseLibrary.Common.Configuration.FileConfigurationSource, Microsoft.Practices.EnterpriseLibrary.Common, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
        filePath="DSC.config" />
      <add name="System Configuration Source" type="Microsoft.Practices.EnterpriseLibrary.Common.Configuration.SystemConfigurationSource, Microsoft.Practices.EnterpriseLibrary.Common, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
    </sources>
  </enterpriseLibrary.ConfigurationSource>





1/20/2009 10:43:39 PM
lukezy
Posts: 2109
Joined: 6/12/2007
Location:WA, US
Re: Trust level
No sure if it makes sense at all. DSC needs FileIOPermission to read/write to these files. Why do we see the security exception here?
DotShoppingCart Staff
1/21/2009 5:38:13 AM
zibi
Posts: 8
Joined: 9/15/2008
Re: Trust level
In Medium trust level FileIOPermission is defined as below
<IPermission class="FileIOPermission" version="1" Read="$AppDir$" Write="$AppDir$" Append="$AppDir$" PathDiscovery="$AppDir$"/>
As we see, we don't have an unrestricted persmission.
 
The question is where should i put those config files to make application work properly (avoid exception)???
1/21/2009 9:07:14 AM
lukezy
Posts: 2109
Joined: 6/12/2007
Location:WA, US
Re: Trust level
I guess so. You probably want to do all the files and folders in step 4.
DotShoppingCart Staff
Page 1 of 2 (14 posts) << First < Prev 1 2 Next > Last >>