Could not load file or assembly

I have a web application in .NET where I am using Ajax controls on some pages. These pages are running on localhost, but the following errors are displayed when hosting pages that have Ajax enabled.

Server error in application "/ Allforkids".

Security Exception

Description: The application attempted to perform an operation that is not permitted by the security policy. To grant this application the required permissions, contact your system administrator or change the application's trust level in the configuration file.

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

Source error:

An unhandled exception was thrown during the execution of the current web request. Information about the origin and location of an exception can be identified using the exception stack trace below.

Stack trace:

[SecurityException: Request for the permission of type 'System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.]
   System.Security.CodeAccessSecurityEngine.Check(Object demand, StackCrawlMark& stackMark, Boolean isPermSet) +0
   System.Security.CodeAccessPermission.Demand() +58
   System.Reflection.Assembly.VerifyCodeBaseDiscovery(String codeBase) +118
   System.Reflection.Assembly.get_CodeBase() +35
   System.Web.Handlers.ScriptResourceHandler.GetCodeBaseWithAssert(Assembly assembly) +31
   System.Web.Handlers.ScriptResourceHandler.GetLastWriteTime(Assembly assembly) +36
   System.Web.Handlers.ScriptResourceHandler.GetAssemblyInfoInternal(Assembly assembly) +61
   System.Web.Handlers.ScriptResourceHandler.GetAssemblyInfo(Assembly assembly) +62
   System.Web.Handlers.RuntimeScriptResourceHandler.System.Web.Handlers.IScriptResourceHandler.GetScriptResourceUrl(Assembly assembly, String resourceName, CultureInfo culture, Boolean zip, Boolean notifyScriptLoaded) +325
   System.Web.Handlers.ScriptResourceHandler.GetScriptResourceUrl(Assembly assembly, String resourceName, CultureInfo culture, Boolean zip, Boolean notifyScriptLoaded) +33
   System.Web.UI.ScriptManager.GetScriptResourceUrl(String resourceName, Assembly assembly) +89
   System.Web.UI.ScriptRegistrationManager.RegisterClientScriptResource(Control control, Type type, String resourceName) +111
   System.Web.UI.ScriptManager.RegisterClientScriptResource(Control control, Type type, String resourceName) +9

      

Version Information: Microsoft .NET Framework Version: 2.0.50727.3082; ASP.NET Version: 2.0.50727.3082

Can anyone give a related solution to get rid of this error?

0


a source to share


3 answers


It looks like something you need to get your hosting provider involved. From this error, you can see that a configuration parameter on the hosting server denies access to local files.

You can try adding this to your web.config:



<system.web>
  ...
  <trust level="Medium" originUrl="" />
  ...
</system.web>

      

But if the hosting provider has a parameter in machine.config that replaces that, that won't make a difference. Here's more information on that.

+1


a source


These could be the security permissions for your folder / files. Are you writing any files (like Access DB)? Make sure your ASP.Net computer account (for example, PCName \ ASPNET) on the server has access to this folder.



+1


a source


Here is the code from the Assembly class:

 private void VerifyCodeBaseDiscovery(String codeBase)
    {                
        if ((codeBase != null) &&
            (String.Compare( codeBase, 0, s_localFilePrefix, 0, 5, true, CultureInfo.InvariantCulture) == 0)) {
            System.Security.Util.URLString urlString = new System.Security.Util.URLString( codeBase );
            new FileIOPermission( FileIOPermissionAccess.PathDiscovery, urlString.GetFileName() ).Demand();
        }
    }

      

An exception was thrown by the .Demand () method with a FileIOPermissionAccess.PathDiscovery request to the file containing the script.

I am assuming the IIS worker process does not have READ / BROW access to the path containing the script.

If you register your scripts in the ScriptManager, check the file path (as a general rule of thumb, scripts should not be in the parent folder (eg .. \ Scripts)).

If this exception is propagated to the AJAX Extensions script resources, there may be a problem installing the AJAX Extensions. You need to ask your hosting provider to check it.

PS. Is there more stack trace available? It seems strange that the first call on the stack is "RegisterClientScriptResource".

0


a source







All Articles