This project is read-only.

AspNetHostingPermission error during MSBuild

Topics: ASP.NET 2.0, Controls
Feb 1, 2011 at 9:36 PM

Hello all

Can anyone help? I have BlogEngine integrated into my website, using the 'blog' subdirectory approach (where you copy what you need to into the App_Code folders etc) - all is well on the development site, but when I try and run the MSBuild automatic deployment to the production site (actually on the same server as the development site) then I get an error complaining about the 'Request for permission ... AspNetHostingPermission ... failed', but the error is only reported for postview.ascx and commentview.ascx

Presumably this is just some sort of permissions issue, but I'm having trouble working out what it is that postview.ascx and commentview.ascx are pointing to that could be causing this error. Does anybody know what sort of thing I should be looking for? It's BlogEngine 1.5 running on a .NET 2.0 site by the way, being built from Visual Studio 2005 SP1.

Thanks if you can help, this has become an obstacle to me using BlogEngine at the moment.



Feb 2, 2011 at 11:03 AM

Is it this error?

With MSBuild, does BE remain a website project?  Does it create a bunch of .DLL files in the /bin directory?  BE is designed to run as a website project, and there have been people in the past that have tried to pre-compile BE or convert it into a WAP project leading to some strange errors.  I'm not sure if this is the case, but what if you just copy/FTP the files as-is without using MSBuild?  That's how we normally test and run BE.

Feb 2, 2011 at 3:41 PM

Hi there

Hmmm, compared to the error you link to, the publickey token is the same but everything else appears to be different - here is my error, and like I say, it is reported as being triggered when MSBuild or ASPNET looks at PostView.ascx or CommentView.ascx in one of the themes:

Request for the permission of type 'System.Web.AspNetHostingPermission, System, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.

Does it still point to an AJAX problem, I have all the usual binding redirects in my web.config, and it is not usually a problem.

Having said that, the specific files mentioned may just be because those are in the first theme that the parser/compiler encounters. The thing is, the deployment process shouldn't even be touching these files really, they are explicitly excluded from the build with a <ExcludeFromBuild /> node in the MSBuild project file, so that they can be ignored by the precompiler, and then just copied over as they are from a specific 'blog' folder within my web app.

By way of explanation, I have a relatively large ASP.NET 2.0 site that needs to be precompiled before deployment to the production server. No problem with this, I've been OK with this for years. To investigate the scope for integrating Blog.Engine into the site, using nested master pages, I followed the procedure for integrating BlogEngine typified here:

This provisionally seemed to work, although clearly there are bound to be some issues for example re: authentication etc, that I will have to tinker with to get full functionality. However, all of this is just on the development site, its no use unless I can successfully deploy to production aswell. As pointed out by ben above, its not really appropriate to try and precompile the blogEngine components and controls, but as far as I can tell, my MSBuild deployment process shouldn't be doing this. It is a shame to have got so far with the integration, I seem to have been frustrated at the last hurdle, just to be stopped by a permissions error, but I don't know how best to troubleshoot it yet as its obviously not my code.

Am I just trying to push blogEngine too far, perhaps I would be better off just writing my own blog components from scratch, after all, blogEngine is not supposed to be used as a portable library of controls really.

Cheers for any advice