DNN Blog

Nov 14

Posted by: Charles Nurse
11/14/2005  RssIcon

This is another issue that crops up regularly on the ASP.NET Forums, so I have decided to create a Blog that I can refer people to.

DotNetNuke 4.0.0 has a number of issues with Medium Trust, due to undocumented changes in how .NET 2 handles partial trust situations.
  1. The first is one of the attributes on the node in web.config, which does not support the compilerOptions attribute under Medium Trust.  Luckily this does not appear to be a problem as removing it apparently causes no other problems.
  2. The second is that the provider sections of the web.config (ie the sections under cannot be parsed under Medium Trust.  This is a new, undocumented change, as the code to parse this worked fine under Medium Trust with .NET 1.1. 
    The solution is to add the attribute requirePermission="false"  to all the provider declaration sections.
       
         
    requirePermission="false" type="DotNetNuke.Framework.Providers.ProviderConfigurationHandler, DotNetNuke" />.
    I only found out the solution to this by carefully reading the error message when the attribute is missing - the default.  As a final irony, adding this attribute causes Intellisense to display a warning that the name "requirePermission" is not declared.
  3. The third change in behaviour that appears to cause problems under Medium Trust is in the behaviour of the XmlSerializer class.  This class gave no partial trust issues in .NET 1.1, but in .NET 2 the constructor we use in DBLoggingProvider:
                xser = New XmlSerializer(obj.GetType, l)
    wher l is an Array of Types that might appear as properties of the main type defined by obj.GetType, throws a trust error.
    This can be replaced by the simpler constructor:
                xser = New XmlSerializer(obj.GetType)
    However, if we do that then we also need to decorate the class defined by obj.GetType, with an Xml attribute that tells the Serializer that this object also contains other classes.
        _
        Public Class LogProperties

I will update this Blog as I find more issue.

Tags:
Categories:
Location: Blogs Parent Separator Charles Nurse

20 comment(s) so far...


Re: DotNetNuke 4.0.0 - Issues with Medium Trust

Hi,
I just want to share my experience. Not looking for a fix, it's just a note that may interest you ?

I try to build and run the install-package of DNN 4.0 in Visual Studio 2005 on a standard 2003 Server running SQL 2000. All permissions in SQL and filepermissions are set correctly (I believe). I've installed the patched version of the sol webcontrols (http://www.dotnetnuke.com/Community/Blogs/tabid/825/EntryID/242/Default.aspx).

First time I try to build I get the following errors:

Error 102 Request for the permission of type 'System.Web.AspNetHostingPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed. W:\newborn\wwwroot\DotNetNuke4\admin\Containers\actions.ascx 3


Error 103 Request for the permission of type 'System.Web.AspNetHostingPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed. W:\newborn\wwwroot\DotNetNuke4\admin\Containers\title.ascx 3

The first error refers to , the second one . Those two continue to produce errors whatever I do.

After commenting out the compiler (1), I still get the above errors along with this one (which pops up now and then):

Warning 104 Name '__ASP' is not CLS-compliant. C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\dotnetnuke4\7864c5a1\8f6184c5\App_Code.c7dkmfry.3.vb 16

After disabling the requirePermission (2) I still got the two first errors.

Point 3 describes the xser = New XmlSerializer(obj.GetType, l). This don't exist in my code. The closest thing is xser = New XmlSerializer(GetType(PortalInfo)) in the Template.ascx.vb file.


The two errors above gives this description when run on the web-server:
The application attempted to perform an operation not allowed by the security policy. To grant this application the required permission please contact your system administrator or change the application's trust level in the configuration file.

Stack Trace:
[SecurityException: Request for the permission of type 'System.Configuration.ConfigurationPermission, System.Configuration, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' failed.]
System.Security.CodeAccessSecurityEngine.Check(Object demand, StackCrawlMark& stackMark, Boolean isPermSet) +0
System.Security.CodeAccessPermission.Demand() +59
System.Configuration.BaseConfigurationRecord.CheckPermissionAllowed(String configKey, Boolean requirePermission, Boolean isTrustedWithoutAptca) +65


If I try to set trust to Full (see http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnpag2/html/paght000020.asp), those two errors still appear when trying to build.

Running the last successfull build now on the webserver produce this error:
Object reference not set to an instance of an object.
In Install\Install.aspx.vb:90 -> xmlConfig = Config.UpdateMachineKey(xmlConfig)

Running it locally produce this error:
Request for the permission of type 'System.Web.AspNetHostingPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed. (W:\newborn\wwwroot\DotNetNuke4\web.config line 38)

Stack Trace:

Line 36:
Line 38:




/Bonavox

By Bonavox on   12/2/2005

Re: DotNetNuke 4.0.0 - Issues with Medium Trust

Hmmm... the blog didnt like the tags, here is the rest of the comment:

Line 36: httpModules
Line 38: add name="UrlRewrite" type="DotNetNuke.HttpModules.UrlRewriteModule, DotNetNuke.HttpModules.UrlRewrite" /


/Bonavox

By Bonavox on   12/2/2005

Re: DotNetNuke 4.0.0 - Issues with Medium Trust

Aw... forget it. I tried to build on a network drive, that didn't work. Please delete my posts :)

/Bonavox

By Bonavox on   12/2/2005

Re: DotNetNuke 4.0.0 - Issues with Medium Trust

i am getting null exception during installation,
i am sure that about full trust issue,

Line 90: xmlConfig = Config.UpdateMachineKey(xmlConfig)

By ferrodoxin on   12/6/2005

Re: DotNetNuke 4.0.0 - Issues with Medium Trust

I was wondering if somebody knows if those issues are fixed in v4.0.1? I cannot a decent source that confirms this.

Many thanks,

Peter Vrenken

By ddookie on   12/8/2005

Re: DotNetNuke 4.0.0 - Issues with Medium Trust

I just tried to buid a 4.0.2 site and it appears there is still a issue with medium trust. I get the Unrecognized attribute 'requirePermission' error. (2003 server, MSSQL express 2005)

I am not looking for a fix, just sharing my experiences..

By cbondura on   1/15/2006

Re: DotNetNuke 4.0.0 - Issues with Medium Trust

Does anybody know hot to fix "Unrecognized attribute 'requirePermission'." error when installing the 4.02 version. Any help is appreciated.

Thanks
Vikas

By vikas_tyagi on   2/19/2006

Re: DotNetNuke 4.0.0 - Issues with Medium Trust

Thanks for not deleting Bonavox's posts... I had the same problem, and his post is the only thing that came up on google.

By twisterjosh on   3/1/2006

Re: DotNetNuke 4.0.0 - Issues with Medium Trust

What can I do....? That would be an interesting thing in that blog...! I have no Problems with creating errors but with fixing errors... ;)
So long

By BK01 on   4/3/2006

Re: DotNetNuke 4.0.0 - Issues with Medium Trust

"Unrecognized attribute 'requirePermission'." is actually not an error - it shows as a warning in VS2005 BUT it is actually a valid attribute. VS2005's Intellisense is not quite right.

By cnurse on   4/6/2006

Re: DotNetNuke 4.0.0 - Issues with Medium Trust

I get the trust error still after successfully building the 4.x source code...The error looks something like this...

Security Exception
Description: The application attempted to perform an operation not allowed by the security policy. To grant this application the required permission please contact your system administrator or change the application's trust level in the configuration file.

Exception Details: System.Security.SecurityException: Request for the permission of type 'System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.

By era_ruler on   4/12/2006

Re: DotNetNuke 4.0.0 - Issues with Medium Trust

i read above that the "requirePermission" error is not an error, but rather a warning. i get this:
"Parser Error Message: Unrecognized attribute 'requirePermission'."

whether it's a warning or an error, i still can't do anything until it goes away and DNN is able to finish installing itself. any help would be greatly appreciated. TIA...
-mike

By devguy165 on   5/1/2006

Re: DotNetNuke 4.0.0 - Issues with Medium Trust

If you use the DotNetNuke starter kit for VS2005 and use it on a Network Drive you get the errors on actions.ascx and title.ascx same Request for permission errors as above.

Has anybody come up with a solution for this, in this case running the solution from a network drive makes a lot of sense.

By chrisbond on   5/22/2006

Re: DotNetNuke 4.0.0 - Issues with Medium Trust

I receive the Configuration error message Unrecognized attribute 'RequirePermission' in line 3 of Webconfig file of the starterskit. I bought DotNetNuke ASP.NET Portals and followed the instructions as descibed in chapter 2. I have no idea how I can solve the problem, also not after reading the above.
When I run the project I get the content of the virtual directory. When I double click the webconfig file, I reach the error message.
Can anybody give me advice? Thanks

By YDV on   10/14/2006

Re: DotNetNuke 4.0.0 - Issues with Medium Trust

Could someone give more detail on point 1. from Charles' three points at the head of this blog.

Finally able to build whole solution. Also build of website only project works fine. But when I try to rebuild or publish the website, I get the following error in the Output window on IDE.

Building directory '/DotNetNuke_2/App_Code/'./: Publication (web): Request for the permission of type 'System.Web.AspNetHostingPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.

I would like to see this thing run.... Not sure what to do at this point

By adlync on   2/12/2007

Re: DotNetNuke 4.0.0 - Issues with Medium Trust

I am also getting the following error messages:

Error 1 Request for the permission of type 'System.Web.AspNetHostingPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed. U:\moesc2007v1\admin\Containers\actions.ascx 3
Error 2 Request for the permission of type 'System.Web.AspNetHostingPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed. U:\moesc2007v1\admin\Containers\title.ascx 3

I am running VWD Express on my local machine, accessing the server on a network drive.

If anyone has any ideas that would be great.

By fbutler on   2/23/2007

Re: DotNetNuke 4.0.0 - Issues with Medium Trust

I'm getting the same error (pasted below).

when building a project on a network drive - has anyone found a solution for this?

Error 1 Request for the permission of type 'System.Web.AspNetHostingPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed. U:\moesc2007v1\admin\Containers\actions.ascx 3
Error 2 Request for the permission of type 'System.Web.AspNetHostingPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed. U:\moesc2007v1\admin\Containers\title.ascx 3

By markMandel on   4/2/2007

Re: DotNetNuke 4.0.0 - Issues with Medium Trust

Information for those receiving errors and trying to work on network drives: http://support.microsoft.com/?id=320268

By briandus on   12/28/2007

Re: DotNetNuke 4.0.0 - Issues with Medium Trust

I am also receiving the same error

Line 4:
Line 5:
Line 6:


Line 7:

Line 8:



Source File: \DotNetNuke\web.config Line: 6

Any help is highly appreciated

By kishore15374 on   1/24/2008
Gravatar

Re: DotNetNuke 4.0.0 - Issues with Medium Trust

I'm also receiving the same error but my website is NOT on a network drive. It is on my secondary D:/ (Data) Drive.

By Carlos Krefft on   7/10/2010
Attend A Webinar
Free Demo Site
Download DotNetNuke Professional Edition Trial
Have Someone Contact Me
Have Someone Contact Me

Like Us on Facebook Join our Network on LinkedIn Follow DNN Corporate on Twitter Follow DNN on Twitter

Advertisers

Sponsors

DotNetNuke Corporation

DotNetNuke Corp. is the steward of the DotNetNuke open source project, the most widely adopted Web Content Management Platform for building web sites and web applications on Microsoft. Organizations use DotNetNuke to quickly develop and deploy interactive and dynamic web sites, intranets, extranets and web applications. The DotNetNuke platform is available in a free Community and subscription-based Professional and Enterprise Editions with an Elite Support option. DotNetNuke Corp. also operates the DotNetNuke Store where users purchase third party apps for the platform.