Required permissions cannot be acquired.

Topics: Bugs, DocSites
Oct 18, 2007 at 6:25 PM
Hi Dave,

I've just tried out 1.8 and the build went fine and works perfectly on my local server under medium trust. However, I've uploaded it onto our webpage and its all gone wrong.

Really not sure what to do, 1.7 works fine and it works under medium trust on my local machine. Any ideas?

Thanks

Ben

The domain is http://beta.docs.mbunit.com/

The error is:

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) +2709488
System.Security.SecurityManager.ResolvePolicy(Evidence evidence, PermissionSet reqdPset, PermissionSet optPset, PermissionSet denyPset, PermissionSet& denied, Int32& securitySpecialFlags, Boolean checkExecutionPermission) +57

FileLoadException: Could not load file or assembly 'DaveSexton.DocProject.DocSites, Version=1.0.0.0, Culture=neutral, PublicKeyToken=af1a4bab65cc4ece' or one of its dependencies. Failed to grant minimum permission requests. (Exception from HRESULT: 0x80131417)
System.Reflection.Assembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection) +0
System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +211
System.Reflection.Assembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +141
System.Reflection.Assembly.Load(String assemblyString) +25
System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +32

ConfigurationErrorsException: Could not load file or assembly 'DaveSexton.DocProject.DocSites, Version=1.0.0.0, Culture=neutral, PublicKeyToken=af1a4bab65cc4ece' or one of its dependencies. Failed to grant minimum permission requests. (Exception from HRESULT: 0x80131417)
System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +596
System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory() +3596761
System.Web.Configuration.CompilationSection.LoadAssembly(AssemblyInfo ai) +46
System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig) +177
System.Web.Compilation.BuildProvidersCompiler..ctor(VirtualPath configPath, Boolean supportLocalization, String outputAssemblyName) +180
System.Web.Compilation.CodeDirectoryCompiler.GetCodeDirectoryAssembly(VirtualPath virtualDir, CodeDirectoryType dirType, String assemblyName, StringSet excludedSubdirectories, Boolean isDirectoryAllowed) +350
System.Web.Compilation.BuildManager.CompileCodeDirectory(VirtualPath virtualDir, CodeDirectoryType dirType, String assemblyName, StringSet excludedSubdirectories) +125
System.Web.Compilation.BuildManager.EnsureTopLevelFilesCompiled() +378

HttpException (0x80004005): Could not load file or assembly 'DaveSexton.DocProject.DocSites, Version=1.0.0.0, Culture=neutral, PublicKeyToken=af1a4bab65cc4ece' or one of its dependencies. Failed to grant minimum permission requests. (Exception from HRESULT: 0x80131417)
System.Web.Compilation.BuildManager.ReportTopLevelCompilationException() +57
System.Web.Compilation.BuildManager.EnsureTopLevelFilesCompiled() +612
System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters) +521

HttpException (0x80004005): Could not load file or assembly 'DaveSexton.DocProject.DocSites, Version=1.0.0.0, Culture=neutral, PublicKeyToken=af1a4bab65cc4ece' or one of its dependencies. Failed to grant minimum permission requests. (Exception from HRESULT: 0x80131417)
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +3540923
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +69
System.Web.HttpRuntime.ProcessRequestInternal(HttpWorkerRequest wr) +275


Coordinator
Oct 19, 2007 at 1:44 AM
Hi Ben,

My mistake :|

It seems that I've added the following attribute to the DaveSexton.DocProject.DocSites project (Properties\AssemblyInfo.cs):

[assembly: PermissionSet(SecurityAction.RequestMinimum, Unrestricted=true)]
but it shouldn't be there.

The DaveSexton.DocProject.DocSites project does not depend on any of the other DocProject projects - only .NET assemblies. If you just open that project in VS, remove the attribute and rebuild, then you can just upload the new .dll to your DocSite's bin folder and that should do the trick.

Please let me know if this works for you and I'll make sure the attribute is gone by the next release.

Thanks,
Dave
Oct 19, 2007 at 6:03 PM
Hi Dave,

Thanks for the reply,

I looked in my AssemblyInfo that attribute wasn't there.

Why would that be?

Thanks

Ben
Coordinator
Oct 19, 2007 at 7:13 PM
Hi Ben,

You have to remove the attribute from the DaveSexton.DocProject.DocSites project, not your DocSite project. You should be able to just load the DaveSexton.DocProject.DocSites.csproj file in Visual Studio by itself, make the modification to the Properties\AssemblyInfo.cs file and rebuild it. Then just deploy the new .dll to your production web server.

You'll find the project in the Source folder, most likely at: C:\Program Files\Dave Sexton\DocProject\Source\DaveSexton.DocProject.DocSites.

Sorry if I wasn't clear :)

NOTE: Before you open the project you should copy the entire Source folder somewhere else; otherwise, if you modify the source code there then Windows Installer will not remove that folder when you uninstall DocProject.

BTW, I'm interested in your feedback about the new DocSite templates and features...

Thanks,
Dave
Oct 19, 2007 at 9:01 PM
Hi Dave,

The DocSite project wasn't included in Program Files, however I downloaded the ChangeSet and now it works fine.

Thanks for your help.

Ben
Coordinator
Oct 19, 2007 at 10:15 PM
Hi Ben,

I don't know why it wasn't there because it's present on my system in the Source folder; regardless though, I'm glad that you got it working :)

- Dave
Coordinator
Oct 24, 2007 at 5:54 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.